-
Notifications
You must be signed in to change notification settings - Fork 500
/
destroy_env_gcp.yml
80 lines (68 loc) · 2.3 KB
/
destroy_env_gcp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
- name: Set up environment for destroy
hosts: localhost
connection: local
become: false
tasks:
- name: Set facts for ssh provision SSH key
when: ssh_provision_key_name is undefined
ansible.builtin.include_role:
name: create_ssh_provision_key
- name: Locate environment SSH key
ansible.builtin.include_role:
name: locate_env_authorized_key
- name: Create GCP credentials file
ansible.builtin.include_role:
name: infra-gcp-credentials-file
- name: Get Google Cloud SDK
ansible.builtin.include_role:
name: infra-gcp-install-sdk
- name: Get private SSH key from secrets
ansible.builtin.include_role:
name: infra-gcp-ssh-key
- name: Run infra-gcp-create-inventory role
ansible.builtin.include_role:
name: infra-gcp-create-inventory
- name: Set ssh extra args for all hosts, use ssh_config just created
hosts: all
gather_facts: false
any_errors_fatal: true
ignore_errors: false
tasks:
- name: Add -F option ansible_ssh_extra_args
when: hostvars['localhost'].ansible_ssh_config is defined
ansible.builtin.set_fact:
ansible_ssh_extra_args: "{{ ansible_ssh_extra_args | default() }} -F {{ hostvars['localhost'].ansible_ssh_config }}"
- name: Start all GCP instances if they are stopped
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- name: Start GCP instances
ansible.builtin.include_tasks: gcp_instances_start.yml
- name: Destroy firewall rules
ansible.builtin.include_tasks: gcp_fw_destroy.yml
- name: Have the OpenShift installer cleanup what it did
hosts: bastions
gather_facts: false
become: false
tasks:
- name: Test the bastion host is available, if not skip host-ocp4-destroy
ansible.builtin.wait_for_connection:
timeout: 60
register: bwait
- name: Call role to destroy the OpenShift cluster
when: bwait is successful
ansible.builtin.include_role:
name: host-ocp4-destroy
- name: Import default cloud provider destroy playbook
ansible.builtin.import_playbook: "../../cloud_providers/{{ cloud_provider }}_destroy_env.yml"
- name: Remove openenv project
hosts: localhost
connection: local
become: false
tasks:
- name: Run the GCP remove project role
ansible.builtin.include_role:
name: open-env-gcp-remove-project