Skip to content

Commit

Permalink
remove firewall rules before running ocp uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Rutledge committed Nov 15, 2023
1 parent d585f3e commit f2024ff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ansible/configs/ocp4-cluster/destroy_env_gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
tasks:
- include_tasks: gcp_instances_start.yml

- name: Destroy firewall rules that openshift-installer created but can't handle
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- include_tasks: gcp_fw_destroy.yml

- name: Have the OpenShift installer cleanup what it did
hosts: bastions
gather_facts: false
Expand Down
19 changes: 19 additions & 0 deletions ansible/configs/ocp4-cluster/gcp_fw_destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Find k8s Firewall Rules in GCP
google.cloud.gcp_compute_firewall_info:
auth_kind: "{{ gcp_auth_type }}"
service_account_file: "{{ gcp_credentials_file }}"
project: "{{ gcp_project_id }}"
register: r_firewall_info

- name: Delete k8s Firewall Rules in GCP
when:
- r_firewall_info.resources | length > 0
- item.name.startswith('k8s-')
google.cloud.gcp_compute_instance:
auth_kind: "{{ gcp_auth_type }}"
service_account_file: "{{ gcp_credentials_file }}"
project: "{{ gcp_project_id }}"
name: "{{ item.name }}"
state: absent
loop: "{{ r_firewall_info.resources }}"

0 comments on commit f2024ff

Please sign in to comment.