48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
# Preflight logging: how many and which packages need to be updated.
|
|
# Run logging steps only when os_update_logging_enabled is true.
|
|
|
|
- name: Logging - Refresh apt cache for accurate preflight
|
|
apt:
|
|
update_cache: yes
|
|
changed_when: false
|
|
when: os_update_logging_enabled | bool
|
|
|
|
- name: Logging - Record start epoch
|
|
command: date +%s
|
|
register: os_update_log_start_ts
|
|
changed_when: false
|
|
when: os_update_logging_enabled | bool
|
|
|
|
- name: Logging - Record start ISO time
|
|
command: date -Iseconds
|
|
register: os_update_log_start_iso
|
|
changed_when: false
|
|
when: os_update_logging_enabled | bool
|
|
|
|
- name: Preflight - Gather upgradable packages
|
|
command: apt list --upgradable
|
|
register: os_update_upgradable
|
|
changed_when: false
|
|
when: os_update_logging_enabled | bool
|
|
|
|
- name: Preflight - Build list of upgradable package names, versions and count
|
|
set_fact:
|
|
os_update_upgradable_names: >-
|
|
{{
|
|
os_update_upgradable.stdout_lines
|
|
| select('search', '\[upgradable')
|
|
| map('regex_replace', '^([^/]+)/.*$', '\1')
|
|
| list
|
|
}}
|
|
os_update_upgradable_versions: >-
|
|
{{
|
|
os_update_upgradable.stdout_lines
|
|
| select('search', '\[upgradable')
|
|
| map('regex_replace', '^([^/]+)/\S+\s+(\S+)\s+\S+\s+\[upgradable from: (\S+)\]$', '\1 \3 \2')
|
|
| list
|
|
}}
|
|
os_update_upgradable_count: >-
|
|
{{
|
|
(os_update_upgradable.stdout_lines | select('search', '\[upgradable') | list | length) | int
|
|
}}
|
|
when: os_update_logging_enabled | bool |