- replace inventory/dmc12.yml with cloudlorean.yml (+ group_vars) and update all README/AGENTS call examples and the inventory table - move admin_password hash into encrypted vault.yml; remove plaintext copies from roles/bootstrap/defaults and group_vars/external.yml - bootstrap.yml loads vault.yml via vars_files (same pattern as monitoring) - monitoring: PSK config/registration updates, docker role defaults, os-updates logging/reboot refinements, ansible.cfg/execute.sh tweaks - add .project-wiki knowledge base and .github agent instructions
103 lines
3.5 KiB
YAML
103 lines
3.5 KiB
YAML
# Reboot decision and execution.
|
|
# Determines whether a reboot is needed because a new kernel was installed,
|
|
# performs the reboot asynchronously, waits for the host to come back, and
|
|
# records timing facts for the update log.
|
|
|
|
- name: Gather running kernel
|
|
command: uname -r
|
|
register: os_update_running_kernel
|
|
changed_when: false
|
|
when: ansible_facts['virtualization_type'] != 'lxc'
|
|
|
|
- name: Gather latest installed kernel
|
|
shell: |
|
|
dpkg -l | grep -E '^ii' | grep 'linux-image-[0-9]' | awk '{print $2}' | sort | tail -n 1
|
|
register: os_update_latest_kernel
|
|
changed_when: false
|
|
failed_when: false
|
|
when: ansible_facts['virtualization_type'] != 'lxc'
|
|
|
|
- name: Determine reboot decision
|
|
set_fact:
|
|
os_update_reboot_required: true
|
|
os_update_reboot_reason: "new kernel installed ({{ os_update_running_kernel.stdout }} -> {{ os_update_latest_kernel.stdout | regex_replace('^linux-image-', '') }})"
|
|
when:
|
|
- ansible_facts['virtualization_type'] != 'lxc'
|
|
- os_update_latest_kernel.stdout | length > 0
|
|
- os_update_running_kernel.stdout not in os_update_latest_kernel.stdout
|
|
|
|
- name: Default reboot decision to false
|
|
set_fact:
|
|
os_update_reboot_required: "{{ os_update_reboot_required | default(false) }}"
|
|
os_update_reboot_reason: "{{ os_update_reboot_reason | default('none') }}"
|
|
|
|
- name: Default reboot timing facts
|
|
set_fact:
|
|
os_update_reboot_triggered: false
|
|
os_update_reboot_deferred: false
|
|
os_update_reboot_start_iso: "n/a"
|
|
os_update_reboot_downtime_seconds: 0
|
|
os_update_running_kernel_after: "{{ os_update_running_kernel.stdout | default('n/a') }}"
|
|
|
|
- name: Notify when reboot is deferred on Proxmox
|
|
ansible.builtin.debug:
|
|
msg: "Reboot required but deferred on Proxmox host {{ ansible_facts['hostname'] }}: {{ os_update_reboot_reason }}"
|
|
when:
|
|
- os_update_reboot_required | bool
|
|
- "'proxmox' in group_names"
|
|
- not os_update_reboot_on_proxmox | bool
|
|
|
|
- name: Record deferred reboot on Proxmox
|
|
ansible.builtin.set_fact:
|
|
os_update_reboot_deferred: true
|
|
when:
|
|
- os_update_reboot_required | bool
|
|
- "'proxmox' in group_names"
|
|
- not os_update_reboot_on_proxmox | bool
|
|
|
|
- block:
|
|
- name: Reboot - Record start time
|
|
command: date -Iseconds
|
|
register: os_update_reboot_start_iso_raw
|
|
changed_when: false
|
|
|
|
- name: Reboot - Record start epoch
|
|
command: date +%s
|
|
register: os_update_reboot_start_ts
|
|
changed_when: false
|
|
|
|
- name: Reboot - Reboot system
|
|
command: /sbin/reboot
|
|
async: 1
|
|
poll: 0
|
|
ignore_errors: true
|
|
|
|
- name: Reboot - Wait for host to come back online
|
|
wait_for_connection:
|
|
delay: 10
|
|
timeout: 600
|
|
register: os_update_reboot_wait
|
|
|
|
- name: Reboot - Record end epoch
|
|
command: date +%s
|
|
register: os_update_reboot_end_ts
|
|
changed_when: false
|
|
|
|
- name: Reboot - Compute downtime
|
|
set_fact:
|
|
os_update_reboot_downtime_seconds: "{{ (os_update_reboot_end_ts.stdout | int) - (os_update_reboot_start_ts.stdout | int) }}"
|
|
|
|
- name: Reboot - Gather running kernel after reboot
|
|
command: uname -r
|
|
register: os_update_running_kernel_after_raw
|
|
changed_when: false
|
|
|
|
- name: Reboot - Record reboot facts
|
|
set_fact:
|
|
os_update_reboot_triggered: true
|
|
os_update_reboot_start_iso: "{{ os_update_reboot_start_iso_raw.stdout }}"
|
|
os_update_running_kernel_after: "{{ os_update_running_kernel_after_raw.stdout }}"
|
|
when:
|
|
- os_update_reboot_required | bool
|
|
- "'proxmox' not in group_names or os_update_reboot_on_proxmox | bool"
|