You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

  1. ---
  2. - hosts: localhost
  3. become: false
  4. gather_facts: no
  5. vars:
  6. expire_days: 2
  7. tasks:
  8. - name: Generate uniq bucket name prefix
  9. raw: date +%Y%m%d
  10. changed_when: false
  11. register: out
  12. - name: replace_test_id
  13. set_fact:
  14. test_name: "kargo-ci-{{ out.stdout_lines[0] }}"
  15. - name: Set file_name for logs
  16. set_fact:
  17. file_name: "{{ ostype }}-{{ kube_network_plugin }}-{{ commit }}-logs.tar.gz"
  18. - name: Create a bucket
  19. gc_storage:
  20. bucket: "{{ test_name }}"
  21. mode: create
  22. permission: public-read
  23. gs_access_key: "{{ gs_key }}"
  24. gs_secret_key: "{{ gs_skey }}"
  25. no_log: True
  26. - name: Create a lifecycle template for the bucket
  27. template:
  28. src: gcs_life.json.j2
  29. dest: "{{ dir }}/gcs_life.json"
  30. mode: 0644
  31. - name: Create a boto config to access GCS
  32. template:
  33. src: boto.j2
  34. dest: "{{ dir }}/.boto"
  35. mode: 0640
  36. no_log: True
  37. - name: Download gsutil cp installer
  38. get_url:
  39. url: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
  40. dest: "{{ dir }}/gcp-installer.sh"
  41. - name: Get gsutil tool
  42. script: "{{ dir }}/gcp-installer.sh"
  43. environment:
  44. CLOUDSDK_CORE_DISABLE_PROMPTS: 1
  45. CLOUDSDK_INSTALL_DIR: "{{ dir }}"
  46. no_log: True
  47. failed_when: false
  48. - name: Apply the lifecycle rules # noqa 301
  49. command: "{{ dir }}/google-cloud-sdk/bin/gsutil lifecycle set {{ dir }}/gcs_life.json gs://{{ test_name }}"
  50. changed_when: false
  51. environment:
  52. BOTO_CONFIG: "{{ dir }}/.boto"
  53. no_log: True
  54. - name: Upload collected diagnostic info
  55. gc_storage:
  56. bucket: "{{ test_name }}"
  57. mode: put
  58. permission: public-read
  59. object: "{{ file_name }}"
  60. src: "{{ dir }}/logs.tar.gz"
  61. headers: '{"Content-Encoding": "x-gzip"}'
  62. gs_access_key: "{{ gs_key }}"
  63. gs_secret_key: "{{ gs_skey }}"
  64. expiration: "{{ expire_days * 36000|int }}"
  65. failed_when: false
  66. no_log: True
  67. - debug: # noqa unnamed-task
  68. msg: "A public url https://storage.googleapis.com/{{ test_name }}/{{ file_name }}"