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