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.

48 lines
1.6 KiB

  1. ---
  2. - hosts: localhost
  3. become: false
  4. gather_facts: no
  5. vars:
  6. mode: default
  7. tasks:
  8. - name: replace_test_id
  9. set_fact:
  10. test_name: "{{ test_id |regex_replace('\\.', '-') }}"
  11. - name: set instance names
  12. set_fact:
  13. instance_names: >-
  14. {%- if mode in ['separate', 'ha'] -%}
  15. k8s-{{ test_name }}-1,k8s-{{ test_name }}-2,k8s-{{ test_name }}-3
  16. {%- else -%}
  17. k8s-{{ test_name }}-1,k8s-{{ test_name }}-2
  18. {%- endif -%}
  19. - name: stop gce instances
  20. google.cloud.gcp_compute_instance:
  21. instance_names: "{{ instance_names }}"
  22. image: "{{ cloud_image | default(omit) }}"
  23. service_account_email: "{{ gce_service_account_email }}"
  24. pem_file: "{{ gce_pem_file | default(omit) }}"
  25. credentials_file: "{{ gce_credentials_file | default(omit) }}"
  26. project_id: "{{ gce_project_id }}"
  27. zone: "{{ cloud_region | default('europe-west1-b') }}"
  28. state: 'stopped'
  29. async: 120
  30. poll: 3
  31. register: gce
  32. - name: delete gce instances
  33. google.cloud.gcp_compute_instance:
  34. instance_names: "{{ instance_names }}"
  35. image: "{{ cloud_image | default(omit) }}"
  36. service_account_email: "{{ gce_service_account_email }}"
  37. pem_file: "{{ gce_pem_file | default(omit) }}"
  38. credentials_file: "{{ gce_credentials_file | default(omit) }}"
  39. project_id: "{{ gce_project_id }}"
  40. zone: "{{ cloud_region | default('europe-west1-b') }}"
  41. state: 'absent'
  42. async: 120
  43. poll: 3
  44. register: gce