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