2019-04-29 16:40:20 +08:00
|
|
|
---
|
2020-07-28 16:39:08 +08:00
|
|
|
- name: Wait for apiserver
|
2022-01-05 18:26:32 +08:00
|
|
|
command: "{{ kubectl }} get nodes"
|
2019-04-29 16:40:20 +08:00
|
|
|
environment:
|
2023-06-26 18:15:45 +08:00
|
|
|
KUBECONFIG: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
|
2019-04-29 16:40:20 +08:00
|
|
|
register: apiserver_is_ready
|
|
|
|
until: apiserver_is_ready.rc == 0
|
|
|
|
retries: 6
|
|
|
|
delay: 10
|
|
|
|
changed_when: false
|
2021-03-24 08:26:05 +08:00
|
|
|
when: groups['broken_kube_control_plane']
|
2019-04-29 16:40:20 +08:00
|
|
|
|
2021-03-24 08:26:05 +08:00
|
|
|
- name: Delete broken kube_control_plane nodes from cluster
|
2022-01-05 18:26:32 +08:00
|
|
|
command: "{{ kubectl }} delete node {{ item }}"
|
2019-04-29 16:40:20 +08:00
|
|
|
environment:
|
2023-06-26 18:15:45 +08:00
|
|
|
KUBECONFIG: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
|
2021-03-24 08:26:05 +08:00
|
|
|
with_items: "{{ groups['broken_kube_control_plane'] }}"
|
2024-09-06 14:56:19 +08:00
|
|
|
register: delete_broken_kube_control_plane_nodes
|
2019-04-29 16:40:20 +08:00
|
|
|
failed_when: false
|
2021-03-24 08:26:05 +08:00
|
|
|
when: groups['broken_kube_control_plane']
|
2019-04-29 16:40:20 +08:00
|
|
|
|
2021-03-24 08:26:05 +08:00
|
|
|
- name: Fail if unable to delete broken kube_control_plane nodes from cluster
|
2019-04-29 16:40:20 +08:00
|
|
|
fail:
|
2021-03-24 08:26:05 +08:00
|
|
|
msg: "Unable to delete broken kube_control_plane node: {{ item.item }}"
|
2024-09-06 14:56:19 +08:00
|
|
|
loop: "{{ delete_broken_kube_control_plane_nodes.results }}"
|
2019-04-29 16:40:20 +08:00
|
|
|
changed_when: false
|
|
|
|
when:
|
2021-03-24 08:26:05 +08:00
|
|
|
- groups['broken_kube_control_plane']
|
2019-04-29 16:40:20 +08:00
|
|
|
- "item.rc != 0 and not 'NotFound' in item.stderr"
|