feat(system_baseline): add an update toggle and pin the pve unattended-upgrades origins
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 35s
Molecule / molecule (pull_request) Successful in 1m46s

system_baseline_update (default true) lets the main flow skip the package
update for hosts patched by a separate, operator-run flow. The update entry
point does not read it: calling it is the request to update.

The new profile key unattended_upgrade_origins is rendered into
/etc/apt/apt.conf.d/90unattended-upgrades-origins, which #clears both
origin lists before setting the pinned patterns, because apt appends list
entries across files and a plain drop-in could only widen them. The pve
profile pins Debian's point-release and security origins, never the
Proxmox repository; the ubuntu profiles pin nothing and are unchanged.

Refs defame1297/ansible-homelab-mono#349

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-11-14 22:11:36 +00:00
1 parent 8a3c7d0fc2
commit 52d06204bb
10 files changed
+181 -7

No files matched your search

@@ -53,6 +53,9 @@
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '03:00'
- system_baseline_secure_tmp_mounts == ['/dev/shm', '/tmp', '/var/tmp']
- system_baseline_update
- system_baseline_unattended_upgrade_origins | length == 3
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
quiet: true
- name: The ubuntu_vm profile resolves
@@ -74,6 +77,7 @@
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
- system_baseline_unattended_upgrade_origins == []
quiet: true
# Consumer play vars override the profile.
@@ -209,3 +209,63 @@
ansible.builtin.assert:
that: not system_baseline_verify_removed.stat.exists
quiet: true
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
# and not in converge, because switching profiles and back would not be idempotent.
- name: The pve profile pins the unattended-upgrades origins
hosts: all
gather_facts: false
tasks:
- name: Stat the origins drop-in after the ubuntu_lxc converge
ansible.builtin.stat:
path: /etc/apt/apt.conf.d/90unattended-upgrades-origins
register: system_baseline_verify_origins_before
- name: The ubuntu_lxc profile pins nothing
ansible.builtin.assert:
that: not system_baseline_verify_origins_before.stat.exists
quiet: true
- name: Run the unattended-upgrades tasks with the pve profile
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: unattended_upgrades
vars:
system_baseline_system_type: pve
- name: Dump the merged apt configuration
ansible.builtin.command: apt-config dump
register: system_baseline_verify_apt_config
changed_when: false
- name: Only the pinned Debian origins are allowed
ansible.builtin.assert:
that:
- >-
system_baseline_verify_apt_config.stdout_lines | select('match', 'Unattended-Upgrade::Origins-Pattern::\s') | list ==
['Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename},label=Debian";',
'Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename},label=Debian-Security";',
'Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename}-security,label=Debian-Security";']
- system_baseline_verify_apt_config.stdout_lines | select('match', 'Unattended-Upgrade::Allowed-Origins::\s') | list == []
quiet: true
- name: Run the unattended-upgrades tasks with the ubuntu_lxc profile again
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: unattended_upgrades
vars:
system_baseline_system_type: ubuntu_lxc
- name: Dump the merged apt configuration again
ansible.builtin.command: apt-config dump
register: system_baseline_verify_apt_config_restored
changed_when: false
- name: The drop-in is gone and the distribution origins are back
ansible.builtin.assert:
that:
- system_baseline_verify_apt_config_restored.stdout_lines | select('match', 'Unattended-Upgrade::Allowed-Origins::\s') | list | length > 0
- system_baseline_verify_apt_config_restored.stdout is not search('origin=Debian')
quiet: true