Files
k3s-ansible/roles/k3s_server/tasks/fetch_k3s_init_logs.yml
T
Timothy Stewart 94dbffaef7 fix(k3s-server): serialize control-plane joins
- Wait for each additional master to register before starting the next\n- Keep k3s initialization diagnostics bounded and sanitized
2026-08-01 12:27:12 -05:00

48 lines
1.3 KiB
YAML

---
# Download logs of k3s-init.service from the nodes to localhost.
# Note that log_destination must be set.
- name: Fetch k3s-init.service logs
ansible.builtin.command:
cmd: >-
timeout --signal=TERM --kill-after=5s 30s journalctl --no-pager
--unit=k3s-init.service --since=-30min --lines=5000
changed_when: false
failed_when: false
no_log: true
register: k3s_init_log
- name: Fetch k3s-init.service status
ansible.builtin.command:
cmd: >-
timeout --signal=TERM --kill-after=5s 15s systemctl status
k3s-init.service --no-pager --full
changed_when: false
failed_when: false
no_log: true
register: k3s_init_status
- name: Create {{ log_destination }}
delegate_to: localhost
run_once: true
become: false
ansible.builtin.file:
path: "{{ log_destination }}"
state: directory
mode: "0755"
- name: Store logs to {{ log_destination }}
delegate_to: localhost
become: false
ansible.builtin.template:
src: content.j2
dest: "{{ log_destination }}/k3s-init@{{ ansible_hostname }}.log"
mode: "0644"
vars:
content: |
=== k3s-init.service status ===
{{ k3s_init_status.stdout | regex_replace('--token(?:=| +)[^ ]+', '--token ***') }}
=== k3s-init.service journal ===
{{ k3s_init_log.stdout | regex_replace('--token(?:=| +)[^ ]+', '--token ***') }}