40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
---
|
|
#
|
|
# These tasks set fact: talos_machine_status
|
|
#
|
|
|
|
- name: Get machine status
|
|
delegate_to: "{{ talosctl_host }}"
|
|
become: false
|
|
ansible.builtin.command:
|
|
cmd: >-
|
|
talosctl get machinestatus
|
|
--endpoints '{{ ansible_host }}'
|
|
--nodes '{{ ansible_host }}'
|
|
--output json
|
|
register: _machine_status_cmd
|
|
failed_when: _machine_status_cmd.rc not in [0, 1]
|
|
changed_when: false
|
|
environment:
|
|
TALOSCONFIG: "{{ talosconfig }}"
|
|
|
|
- name: Get machine status - insecure
|
|
when: "_machine_status_cmd.rc == 1"
|
|
delegate_to: "{{ talosctl_host }}"
|
|
become: false
|
|
ansible.builtin.command:
|
|
cmd: >-
|
|
talosctl get machinestatus
|
|
--endpoints '{{ ansible_host }}'
|
|
--nodes '{{ ansible_host }}'
|
|
--output json
|
|
--insecure
|
|
register: _machine_status_cmd_insec
|
|
changed_when: false
|
|
environment:
|
|
TALOSCONFIG: "{{ talosconfig }}"
|
|
|
|
- name: Parse machine status
|
|
ansible.builtin.set_fact:
|
|
talos_machine_status: "{{ _machine_status_cmd_insec.stdout | default(_machine_status_cmd.stdout) | from_json }}"
|