snel.kubernetes-cluster/roles/dci_reinstall_talos/tasks/main.yml

58 lines
1.8 KiB
YAML

---
# This role does not wipe the disks.
# If there is still a Talos config present on disk, the server will not go in Maintenance stage.
# You can clear the disk using DCI Manager: https://dcimanager6.snel.com/auth/login
- name: Sleep 2 minutes because we just called the 'Finish' operation at DCI Manager
when: dci_finish_called is defined
ansible.builtin.pause:
prompt: Please wait
seconds: 120
- name: Call DCI Manager API to reinstall Talos Linux
delegate_to: "{{ dci_manager_access_host }}"
become: false
ansible.builtin.uri:
url: "{{ dci_manager_protocol }}://{{ dci_manager_host }}:{{ dci_manager_port }}/dci/v3/server/{{ dci_server_info.id }}/operation_os"
method: POST
return_content: true
headers:
Accept: application/json
X-Xsrf-Token: "{{ dci_token }}"
body_format: json
body:
hdd_raid: "no_raid"
os_template_id: "{{ dci_manager_talos_os_template_id }}"
password: "_not_used_"
register: _dci_reinstall
until: _dci_reinstall.status != 503 and _dci_reinstall.status != -1
changed_when: true
- name: Wait for Talos port 50000 to go down
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.wait_for:
delay: 10
state: stopped
host: "{{ ansible_host }}"
port: 50000
timeout: 300
- name: Wait for Talos port 50000 to be open
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.wait_for:
delay: 10
host: "{{ ansible_host }}"
port: 50000
timeout: 1200
- name: Import talos_machine_status tasks
ansible.builtin.import_tasks: "{{ role_path }}/../../shared/tasks/talos_machine_status.yml"
- name: Verify Talos is in Maintenance stage
ansible.builtin.assert:
that: "talos_machine_status.spec.stage == 'maintenance'"
quiet: true