Skip to content

Commit 16bea45

Browse files
committed
Updates from review
1 parent 50f040b commit 16bea45

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

roles/capi_cluster/tasks/main.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,36 @@
104104
dest: "{{ capi_cluster_kubeconfig_path }}"
105105
mode: u=rw,g=,o=
106106

107-
- name: Including token-based kubeconfig tasks to generate token-based kubeconfig
108-
when: capi_cluster_service_account_enabled
109-
environment:
110-
KUBECONFIG: "{{ capi_cluster_kubeconfig_path }}"
111-
block:
112-
- name: Include token-based kubeconfig task file
113-
ansible.builtin.include_tasks: capi-cluster-service-account.yml
107+
- name: Including token-based kubeconfig tasks to generate token-based kubeconfig
108+
when: capi_cluster_service_account_enabled
109+
environment:
110+
KUBECONFIG: "{{ capi_cluster_kubeconfig_path }}"
111+
block:
112+
- name: Include token-based kubeconfig task file
113+
ansible.builtin.include_tasks: capi-cluster-service-account.yml
114114

115115
- name: Check that the cluster exists
116116
ansible.builtin.command: >-
117117
kubectl get
118118
openstackclusters.infrastructure.cluster.x-k8s.io
119119
-n {{ capi_cluster_release_namespace }}
120120
{{ capi_cluster_release_name }}
121-
ignore_errors: true
121+
--ignore-not-found true
122+
-o json
122123
changed_when: false
123124
register: cluster_check
124125
when: capi_cluster_release_state == 'absent'
125126

127+
- name: Set fact from cluster check
128+
ansible.builtin.set_fact:
129+
cluster_details: "{{ cluster_check.stdout | from_json }}"
130+
changed_when: false
131+
when: capi_cluster_release_state == 'absent'
132+
126133
- name: Delete CAPI cluster
127134
when:
128135
- capi_cluster_release_state == 'absent'
129-
- cluster_check.rc == 0
136+
- cluster_details.items is defined and cluster_details.items | length == 1
130137
block:
131138
# Before deleting the cluster, update the annotation that indicates if volumes should be kept
132139
- name: Set volumes policy annotation

0 commit comments

Comments
 (0)