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