2016-11-03 20:57:33 +08:00
|
|
|
---
|
|
|
|
- hosts: localhost
|
|
|
|
become: false
|
|
|
|
gather_facts: no
|
|
|
|
|
2016-11-09 21:15:27 +08:00
|
|
|
vars:
|
|
|
|
expire_days: 2
|
|
|
|
|
2016-11-03 20:57:33 +08:00
|
|
|
tasks:
|
2016-11-07 23:00:49 +08:00
|
|
|
- name: Generate uniq bucket name prefix
|
2016-11-16 18:30:00 +08:00
|
|
|
raw: date +%Y%m%d
|
2016-11-07 23:00:49 +08:00
|
|
|
register: out
|
|
|
|
|
2016-11-03 20:57:33 +08:00
|
|
|
- name: replace_test_id
|
|
|
|
set_fact:
|
2016-11-16 18:30:00 +08:00
|
|
|
test_name: "kargo-ci-{{ out.stdout_lines[0] }}"
|
2016-11-09 21:15:27 +08:00
|
|
|
|
|
|
|
- set_fact:
|
2019-05-03 05:24:21 +08:00
|
|
|
file_name: "{{ ostype }}-{{ kube_network_plugin }}-{{ commit }}-logs.tar.gz"
|
2016-11-03 20:57:33 +08:00
|
|
|
|
|
|
|
- name: Create a bucket
|
|
|
|
gc_storage:
|
|
|
|
bucket: "{{ test_name }}"
|
|
|
|
mode: create
|
2016-11-09 21:15:27 +08:00
|
|
|
permission: public-read
|
2016-11-07 23:00:49 +08:00
|
|
|
gs_access_key: "{{ gs_key }}"
|
|
|
|
gs_secret_key: "{{ gs_skey }}"
|
|
|
|
no_log: True
|
|
|
|
|
2016-11-09 21:15:27 +08:00
|
|
|
- name: Create a lifecycle template for the bucket
|
|
|
|
template:
|
|
|
|
src: gcs_life.json.j2
|
2019-05-03 05:24:21 +08:00
|
|
|
dest: "{{ dir }}/gcs_life.json"
|
2016-11-09 21:15:27 +08:00
|
|
|
|
|
|
|
- name: Create a boto config to access GCS
|
|
|
|
template:
|
|
|
|
src: boto.j2
|
2019-05-03 05:24:21 +08:00
|
|
|
dest: "{{ dir }}/.boto"
|
2016-11-09 21:15:27 +08:00
|
|
|
no_log: True
|
|
|
|
|
2016-11-07 23:00:49 +08:00
|
|
|
- name: Download gsutil cp installer
|
|
|
|
get_url:
|
|
|
|
url: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
|
2019-05-03 05:24:21 +08:00
|
|
|
dest: "{{ dir }}/gcp-installer.sh"
|
2016-11-07 23:00:49 +08:00
|
|
|
|
|
|
|
- name: Get gsutil tool
|
2019-05-03 05:24:21 +08:00
|
|
|
script: "{{ dir }}/gcp-installer.sh"
|
2016-11-07 23:00:49 +08:00
|
|
|
environment:
|
|
|
|
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
|
2019-05-03 05:24:21 +08:00
|
|
|
CLOUDSDK_INSTALL_DIR: "{{ dir }}"
|
2016-11-07 23:00:49 +08:00
|
|
|
no_log: True
|
2016-12-27 19:38:54 +08:00
|
|
|
failed_when: false
|
2016-11-07 23:00:49 +08:00
|
|
|
|
|
|
|
- name: Apply the lifecycle rules
|
2019-05-03 05:24:21 +08:00
|
|
|
command: "{{ dir }}/google-cloud-sdk/bin/gsutil lifecycle set {{ dir }}/gcs_life.json gs://{{ test_name }}"
|
2016-11-07 23:00:49 +08:00
|
|
|
environment:
|
2019-05-03 05:24:21 +08:00
|
|
|
BOTO_CONFIG: "{{ dir }}/.boto"
|
2016-11-09 21:15:27 +08:00
|
|
|
no_log: True
|
2016-11-03 20:57:33 +08:00
|
|
|
|
|
|
|
- name: Upload collected diagnostic info
|
|
|
|
gc_storage:
|
|
|
|
bucket: "{{ test_name }}"
|
|
|
|
mode: put
|
2016-11-09 21:15:27 +08:00
|
|
|
permission: public-read
|
|
|
|
object: "{{ file_name }}"
|
2019-05-03 05:24:21 +08:00
|
|
|
src: "{{ dir }}/logs.tar.gz"
|
2016-11-07 23:00:49 +08:00
|
|
|
headers: '{"Content-Encoding": "x-gzip"}'
|
|
|
|
gs_access_key: "{{ gs_key }}"
|
|
|
|
gs_secret_key: "{{ gs_skey }}"
|
2019-05-03 05:24:21 +08:00
|
|
|
expiration: "{{ expire_days * 36000|int }}"
|
2016-12-27 19:38:54 +08:00
|
|
|
failed_when: false
|
2016-11-09 21:15:27 +08:00
|
|
|
no_log: True
|
|
|
|
|
|
|
|
- debug:
|
2019-05-03 05:24:21 +08:00
|
|
|
msg: "A public url https://storage.googleapis.com/{{ test_name }}/{{ file_name }}"
|