chore: capture k3s secondary install diagnostics on failure
This commit is contained in:
@@ -67,13 +67,45 @@
|
|||||||
- k3s_primary | default(false)
|
- k3s_primary | default(false)
|
||||||
|
|
||||||
- name: Install k3s server (secondary)
|
- name: Install k3s server (secondary)
|
||||||
environment:
|
when:
|
||||||
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
|
|
||||||
K3S_TOKEN: "{{ k3s_token }}"
|
|
||||||
command: /tmp/install-k3s.sh server --server https://{{ k3s_primary_ip }}:6443 --advertise-address={{ k3s_node_ip }} --node-ip={{ k3s_node_ip }}
|
|
||||||
when:
|
|
||||||
- k3s_install_needed
|
- k3s_install_needed
|
||||||
- not (k3s_primary | default(false))
|
- not (k3s_primary | default(false))
|
||||||
|
block:
|
||||||
|
- name: Run secondary k3s install
|
||||||
|
environment:
|
||||||
|
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
|
||||||
|
K3S_TOKEN: "{{ k3s_token }}"
|
||||||
|
command: /tmp/install-k3s.sh server --server https://{{ k3s_primary_ip }}:6443 --advertise-address={{ k3s_node_ip }} --node-ip={{ k3s_node_ip }}
|
||||||
|
register: secondary_install
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Show k3s service status after failed secondary install
|
||||||
|
command: systemctl status k3s --no-pager
|
||||||
|
register: k3s_status_after_install
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Show recent k3s logs after failed secondary install
|
||||||
|
command: journalctl -u k3s -n 120 --no-pager
|
||||||
|
register: k3s_journal_after_install
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Fail with secondary install diagnostics
|
||||||
|
fail:
|
||||||
|
msg: |
|
||||||
|
Secondary k3s install failed on {{ inventory_hostname }}.
|
||||||
|
Install stdout:
|
||||||
|
{{ secondary_install.stdout | default('n/a') }}
|
||||||
|
|
||||||
|
Install stderr:
|
||||||
|
{{ secondary_install.stderr | default('n/a') }}
|
||||||
|
|
||||||
|
Service status:
|
||||||
|
{{ k3s_status_after_install.stdout | default('n/a') }}
|
||||||
|
|
||||||
|
Recent logs:
|
||||||
|
{{ k3s_journal_after_install.stdout | default('n/a') }}
|
||||||
|
|
||||||
- name: Wait for k3s to be ready
|
- name: Wait for k3s to be ready
|
||||||
command: "{{ (k3s_primary | default(false)) | ternary('kubectl get nodes', 'systemctl is-active k3s') }}"
|
command: "{{ (k3s_primary | default(false)) | ternary('kubectl get nodes', 'systemctl is-active k3s') }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user