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.

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