2019-04-29 08:40:20 +00:00
|
|
|
---
|
2020-07-28 08:39:08 +00:00
|
|
|
- name: Wait for apiserver
|
|
|
|
command: "{{ bin_dir }}/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
|
2020-02-11 09:38:01 +00:00
|
|
|
when: groups['broken_kube-master']
|
2019-04-29 08:40:20 +00:00
|
|
|
|
2020-07-28 08:39:08 +00:00
|
|
|
- name: Delete broken kube-master nodes from cluster
|
|
|
|
command: "{{ bin_dir }}/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"
|
2020-02-11 09:38:01 +00:00
|
|
|
with_items: "{{ groups['broken_kube-master'] }}"
|
|
|
|
register: delete_broken_kube_masters
|
2019-04-29 08:40:20 +00:00
|
|
|
failed_when: false
|
2020-02-11 09:38:01 +00:00
|
|
|
when: groups['broken_kube-master']
|
2019-04-29 08:40:20 +00:00
|
|
|
|
2020-02-11 09:38:01 +00:00
|
|
|
- name: Fail if unable to delete broken kube-master nodes from cluster
|
2019-04-29 08:40:20 +00:00
|
|
|
fail:
|
2020-02-11 09:38:01 +00:00
|
|
|
msg: "Unable to delete broken kube-master node: {{ item.item }}"
|
|
|
|
loop: "{{ delete_broken_kube_masters.results }}"
|
2019-04-29 08:40:20 +00:00
|
|
|
changed_when: false
|
|
|
|
when:
|
2020-02-11 09:38:01 +00:00
|
|
|
- groups['broken_kube-master']
|
2019-04-29 08:40:20 +00:00
|
|
|
- "item.rc != 0 and not 'NotFound' in item.stderr"
|