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.

78 lines
2.1 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. - name: Create a boto config to access GCS
  31. template:
  32. src: boto.j2
  33. dest: "{{ dir }}/.boto"
  34. no_log: True
  35. - name: Download gsutil cp installer
  36. get_url:
  37. url: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
  38. dest: "{{ dir }}/gcp-installer.sh"
  39. - name: Get gsutil tool
  40. script: "{{ dir }}/gcp-installer.sh"
  41. environment:
  42. CLOUDSDK_CORE_DISABLE_PROMPTS: 1
  43. CLOUDSDK_INSTALL_DIR: "{{ dir }}"
  44. no_log: True
  45. failed_when: false
  46. - name: Apply the lifecycle rules # noqa 301
  47. command: "{{ dir }}/google-cloud-sdk/bin/gsutil lifecycle set {{ dir }}/gcs_life.json gs://{{ test_name }}"
  48. changed_when: false
  49. environment:
  50. BOTO_CONFIG: "{{ dir }}/.boto"
  51. no_log: True
  52. - name: Upload collected diagnostic info
  53. gc_storage:
  54. bucket: "{{ test_name }}"
  55. mode: put
  56. permission: public-read
  57. object: "{{ file_name }}"
  58. src: "{{ dir }}/logs.tar.gz"
  59. headers: '{"Content-Encoding": "x-gzip"}'
  60. gs_access_key: "{{ gs_key }}"
  61. gs_secret_key: "{{ gs_skey }}"
  62. expiration: "{{ expire_days * 36000|int }}"
  63. failed_when: false
  64. no_log: True
  65. - debug:
  66. msg: "A public url https://storage.googleapis.com/{{ test_name }}/{{ file_name }}"