2023-03-27 17:25:55 +08:00
|
|
|
---
|
2023-12-05 06:24:00 +08:00
|
|
|
- name: Common tasks for every playbooks
|
|
|
|
import_playbook: boilerplate.yml
|
2023-03-27 17:25:55 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Confirm node removal
|
|
|
|
hosts: "{{ node | default('etcd:k8s_cluster:calico_rr') }}"
|
2024-08-28 13:30:56 +08:00
|
|
|
gather_facts: false
|
2023-03-27 17:25:55 +08:00
|
|
|
tasks:
|
|
|
|
- name: Confirm Execution
|
|
|
|
pause:
|
|
|
|
prompt: "Are you sure you want to delete nodes state? Type 'yes' to delete nodes."
|
|
|
|
register: pause_result
|
2024-08-28 13:30:56 +08:00
|
|
|
run_once: true
|
2023-03-27 17:25:55 +08:00
|
|
|
when:
|
|
|
|
- not (skip_confirmation | default(false) | bool)
|
|
|
|
|
|
|
|
- name: Fail if user does not confirm deletion
|
|
|
|
fail:
|
|
|
|
msg: "Delete nodes confirmation failed"
|
|
|
|
when: pause_result.user_input | default('yes') != 'yes'
|
|
|
|
|
|
|
|
- name: Gather facts
|
|
|
|
import_playbook: facts.yml
|
2023-07-05 11:36:54 +08:00
|
|
|
when: reset_nodes | default(True) | bool
|
2023-03-27 17:25:55 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Reset node
|
|
|
|
hosts: "{{ node | default('kube_node') }}"
|
2024-08-28 13:30:56 +08:00
|
|
|
gather_facts: false
|
2023-03-27 17:25:55 +08:00
|
|
|
environment: "{{ proxy_disable_env }}"
|
2024-10-15 15:50:22 +08:00
|
|
|
pre_tasks:
|
|
|
|
- name: Gather information about installed services
|
|
|
|
service_facts:
|
|
|
|
when: reset_nodes | default(True) | bool
|
2023-03-27 17:25:55 +08:00
|
|
|
roles:
|
2023-07-05 11:36:54 +08:00
|
|
|
- { role: kubespray-defaults, when: reset_nodes | default(True) | bool }
|
2023-03-27 17:25:55 +08:00
|
|
|
- { role: remove-node/pre-remove, tags: pre-remove }
|
2024-09-05 11:53:28 +08:00
|
|
|
- role: remove-node/remove-etcd-node
|
|
|
|
when: "'etcd' in group_names"
|
2023-07-05 11:36:54 +08:00
|
|
|
- { role: reset, tags: reset, when: reset_nodes | default(True) | bool }
|
2023-03-27 17:25:55 +08:00
|
|
|
|
2024-09-06 14:56:19 +08:00
|
|
|
# Currently cannot remove first control plane node or first etcd node
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Post node removal
|
|
|
|
hosts: "{{ node | default('kube_control_plane[1:]:etcd[1:]') }}"
|
2024-08-28 13:30:56 +08:00
|
|
|
gather_facts: false
|
2023-03-27 17:25:55 +08:00
|
|
|
environment: "{{ proxy_disable_env }}"
|
|
|
|
roles:
|
2023-07-05 11:36:54 +08:00
|
|
|
- { role: kubespray-defaults, when: reset_nodes | default(True) | bool }
|
2023-03-27 17:25:55 +08:00
|
|
|
- { role: remove-node/post-remove, tags: post-remove }
|