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.

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