Files
ansible-playbooks/roles/os-updates/tasks/logging_postflight.yml
T
DerLinkman 30f3e9a4c6 rename dmc12 inventory to cloudlorean and vault admin_password
- 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
2026-09-09 14:14:18 +02:00

48 lines
1.9 KiB
YAML

# Postflight logging: which packages were updated and how long it took.
# Run logging steps only when os_update_logging_enabled is true.
- name: Logging - Record end epoch
command: date +%s
register: os_update_log_end_ts
changed_when: false
when: os_update_logging_enabled | bool
- name: Logging - Compute upgrade duration
set_fact:
os_update_duration_seconds: "{{ (os_update_log_end_ts.stdout | int) - (os_update_log_start_ts.stdout | int) }}"
when: os_update_logging_enabled | bool
- name: Logging - Ensure log directory exists
file:
path: "{{ os_update_log_file | dirname }}"
state: directory
delegate_to: localhost
when: os_update_logging_enabled | bool
- name: Logging - Write update log entry
blockinfile:
path: "{{ os_update_log_file }}"
create: yes
marker: "# {mark} ANSIBLE-OS-UPDATE"
block: |
host: {{ ansible_facts['hostname'] }}
started: {{ os_update_log_start_iso.stdout }}
duration_seconds: {{ os_update_duration_seconds }}
upgradable_packages_count: {{ os_update_upgradable_count }}
upgrade_changed: {{ os_update_upgrade_result.changed | default(false) }}
upgrade_failed: {{ os_update_upgrade_result.failed | default(false) }}
upgradable_packages:
{% for ver in os_update_upgradable_versions %}
- {{ ver.split()[0] }} ({{ ver.split()[1] }} -> {{ ver.split()[2] }})
{% endfor %}
reboot_required: {{ os_update_reboot_required }}
reboot_reason: {{ os_update_reboot_reason }}
reboot_triggered: {{ os_update_reboot_triggered }}
reboot_deferred: {{ os_update_reboot_deferred }}
reboot_started: {{ os_update_reboot_start_iso }}
reboot_downtime_seconds: {{ os_update_reboot_downtime_seconds }}
kernel_before: {{ os_update_running_kernel.stdout | default('n/a') }}
kernel_after: {{ os_update_running_kernel_after }}
delegate_to: localhost
when: os_update_logging_enabled | bool