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

70 lines
1.8 KiB
YAML

---
- name: Directory for configs
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.file:
path: "{{ talos_cluster_config_dir }}"
state: directory
mode: u=rwX,go=
- name: Import talos_machine_status tasks
ansible.builtin.import_tasks: "{{ role_path }}/../../shared/tasks/talos_machine_status.yml"
- name: Try Talos node config
delegate_to: "{{ talosctl_host }}"
become: no
ansible.builtin.command:
cmd: >-
talosctl apply-config
--file '{{ talos_node_config_file }}'
--nodes '{{ ansible_remote }}'
--endpoints '{{ ansible_remote }}'
--mode reboot
--timeout 2m
{% if talos_machine_status.spec.stage == 'maintenance' %} --insecure{% endif %}
changed_when: true
environment:
TALOSCONFIG: "{{ talosconfig }}"
- name: Wait for Talos port 50000 to close
delegate_to: "{{ talosctl_host }}"
become: no
ansible.builtin.wait_for:
host: "{{ ansible_remote }}"
port: 50000
timeout: 100
state: stopped
- name: Wait for Talos port 50000 to open
delegate_to: "{{ talosctl_host }}"
become: no
ansible.builtin.wait_for:
host: "{{ ansible_remote }}"
port: 50000
delay: 5
timeout: 100
- name: Apply Talos node config
delegate_to: "{{ talosctl_host }}"
become: no
ansible.builtin.command:
cmd: >-
talosctl apply-config
--file '{{ talos_node_config_file }}'
--nodes '{{ ansible_remote }}'
--endpoints '{{ ansible_remote }}'
--mode auto
{% if talos_machine_status.spec.stage == 'maintenance' %} --insecure{% endif %}
changed_when: true
environment:
TALOSCONFIG: "{{ talosconfig }}"
- name: Wait for Talos port 50000
delegate_to: "{{ talosctl_host }}"
become: no
ansible.builtin.wait_for:
host: "{{ ansible_remote }}"
port: 50000
delay: 5
timeout: 60