2019-04-29 16:40:20 +08:00
|
|
|
---
|
2020-07-27 21:24:17 +08:00
|
|
|
- name: Wait for apiserver # noqa 305
|
2019-04-29 16:40:20 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl get nodes"
|
|
|
|
environment:
|
2019-06-06 17:06:11 +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
|
2020-02-11 17:38:01 +08:00
|
|
|
when: groups['broken_kube-master']
|
2019-04-29 16:40:20 +08:00
|
|
|
|
2020-07-27 21:24:17 +08:00
|
|
|
- name: Delete broken kube-master nodes from cluster # noqa 305
|
2019-04-29 16:40:20 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl delete node {{ item }}"
|
|
|
|
environment:
|
2019-06-06 17:06:11 +08:00
|
|
|
- KUBECONFIG: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
|
2020-02-11 17:38:01 +08:00
|
|
|
with_items: "{{ groups['broken_kube-master'] }}"
|
|
|
|
register: delete_broken_kube_masters
|
2019-04-29 16:40:20 +08:00
|
|
|
failed_when: false
|
2020-02-11 17:38:01 +08:00
|
|
|
when: groups['broken_kube-master']
|
2019-04-29 16:40:20 +08:00
|
|
|
|
2020-02-11 17:38:01 +08:00
|
|
|
- name: Fail if unable to delete broken kube-master nodes from cluster
|
2019-04-29 16:40:20 +08:00
|
|
|
fail:
|
2020-02-11 17:38:01 +08:00
|
|
|
msg: "Unable to delete broken kube-master node: {{ item.item }}"
|
|
|
|
loop: "{{ delete_broken_kube_masters.results }}"
|
2019-04-29 16:40:20 +08:00
|
|
|
changed_when: false
|
|
|
|
when:
|
2020-02-11 17:38:01 +08:00
|
|
|
- groups['broken_kube-master']
|
2019-04-29 16:40:20 +08:00
|
|
|
- "item.rc != 0 and not 'NotFound' in item.stderr"
|