deprovision.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---
  2. - name: Fetch instance group managers
  3. gcp_compute_instance_group_manager_facts:
  4. auth_kind: serviceaccount
  5. scopes:
  6. - https://www.googleapis.com/auth/compute
  7. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  8. project: "{{ openshift_gcp_project }}"
  9. zone: "{{ openshift_gcp_zone }}"
  10. filters:
  11. - "name : {{ openshift_gcp_prefix }}ig*"
  12. register: instance_group_managers
  13. - name: Fetch instance templates
  14. gcp_compute_instance_template_facts:
  15. auth_kind: serviceaccount
  16. scopes:
  17. - https://www.googleapis.com/auth/compute
  18. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  19. project: "{{ openshift_gcp_project }}"
  20. filters:
  21. - "name : {{ openshift_gcp_prefix }}instance-template*"
  22. register: instance_templates
  23. - name: Remove GCP Instance Groups
  24. gcp_compute_instance_group_manager:
  25. auth_kind: serviceaccount
  26. scopes:
  27. - https://www.googleapis.com/auth/compute
  28. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  29. project: "{{ openshift_gcp_project }}"
  30. zone: "{{ openshift_gcp_zone }}"
  31. name: "{{ item[0].name }}"
  32. base_instance_name: "{{ item[0].name }}"
  33. instance_template: "{{ item[1] }}"
  34. state: absent
  35. with_nested:
  36. - "{{ instance_group_managers['items'] }}"
  37. - "{{ instance_templates['items'] }}"
  38. - name: Remove GCP instance templates
  39. gcp_compute_instance_template:
  40. auth_kind: serviceaccount
  41. scopes:
  42. - https://www.googleapis.com/auth/compute
  43. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  44. project: "{{ openshift_gcp_project }}"
  45. name: "{{ item.name }}"
  46. state: absent
  47. with_items: "{{ instance_templates['items'] }}"
  48. - name: Remove GCP firewall
  49. gcp_compute_firewall:
  50. auth_kind: serviceaccount
  51. scopes:
  52. - https://www.googleapis.com/auth/compute
  53. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  54. project: "{{ openshift_gcp_project }}"
  55. name: "{{ openshift_gcp_prefix }}{{ item.rule }}"
  56. state: absent
  57. with_items: "{{ openshift_gcp_firewall_rules }}"
  58. - name: Remove GCP network
  59. gcp_compute_network:
  60. auth_kind: serviceaccount
  61. scopes:
  62. - https://www.googleapis.com/auth/compute
  63. service_account_file: "{{ openshift_gcp_iam_service_account_keyfile }}"
  64. project: "{{ openshift_gcp_project }}"
  65. name: "{{ openshift_gcp_network_name }}"
  66. state: absent
  67. - name: Templatize DNS script
  68. template: src=remove.j2.sh dest=/tmp/remove.sh mode=u+rx
  69. - name: Run DNS cleanup script
  70. command: /tmp/remove.sh
  71. args:
  72. chdir: "{{ files_dir }}"