diff --git a/changelogs/fragments/system-baseline-update-toggle.yml b/changelogs/fragments/system-baseline-update-toggle.yml index 3298a5a..f3b3cde 100644 --- a/changelogs/fragments/system-baseline-update-toggle.yml +++ b/changelogs/fragments/system-baseline-update-toggle.yml @@ -8,4 +8,8 @@ minor_changes: A non-empty list is written to ``/etc/apt/apt.conf.d/90unattended-upgrades-origins``, which clears the earlier ``Allowed-Origins`` and ``Origins-Pattern`` lists and allows only the listed patterns. The ``pve`` profile now pins Debian's point-release and security origins, so the Proxmox repository is never upgraded unattended and a future Debian default - cannot widen the set. The ``ubuntu_lxc`` and ``ubuntu_vm`` profiles pin nothing and are unchanged. + cannot widen the set. On ``pve`` hosts this also removes any origin an operator added in ``50unattended-upgrades`` or + another earlier ``apt.conf.d`` file (``Allowed-Origins`` included). To keep them, opt out with + ``system_baseline_profile_overrides: {pve: {unattended_upgrade_origins: []}}`` or set + ``system_baseline_unattended_upgrade_origins: []``; the role then removes the drop-in. The ``ubuntu_lxc`` and + ``ubuntu_vm`` profiles pin nothing and are unchanged. diff --git a/roles/system_baseline/README.md b/roles/system_baseline/README.md index a57711e..6549f73 100644 --- a/roles/system_baseline/README.md +++ b/roles/system_baseline/README.md @@ -126,7 +126,7 @@ A profile's `unattended_upgrade_origins` list pins the origins unattended-upgrad - `pve` pins Debian's own default set: `origin=Debian,codename=${distro_codename},label=Debian` (point releases) and the two `Debian-Security` patterns. The Proxmox repository is never allowed, and a future Debian default cannot widen the set. - `ubuntu_lxc` and `ubuntu_vm` pin nothing (`[]`): Ubuntu's default origins apply. - `${distro_codename}` is expanded by unattended-upgrades, not by Ansible. An entry may not hold a double quote, a backslash or a line break. -- A file in `/etc/apt/apt.conf.d` that sorts after `90unattended-upgrades-origins` can still add origins. +- A file in `/etc/apt/apt.conf.d` that sorts after `90unattended-upgrades-origins` can still add origins, and so can `/etc/apt/apt.conf`, which apt reads after `apt.conf.d`. - Check the merged result on a host with `apt-config dump | grep -E 'Unattended-Upgrade::(Origins-Pattern|Allowed-Origins)'`. ## Notes diff --git a/roles/system_baseline/molecule/default/verify.yml b/roles/system_baseline/molecule/default/verify.yml index 8303d0d..9777b50 100644 --- a/roles/system_baseline/molecule/default/verify.yml +++ b/roles/system_baseline/molecule/default/verify.yml @@ -213,7 +213,8 @@ # 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. +# and not in converge, because switching profiles and back would not be idempotent. Applying the pve profile also rewrites +# the 50unattended-upgrades keys (Automatic-Reboot-Time 03:00); the ubuntu_lxc re-run at the end restores them. - name: The pve profile pins the unattended-upgrades origins hosts: all gather_facts: false diff --git a/roles/system_baseline/tasks/validate.yml b/roles/system_baseline/tasks/validate.yml index 576e125..1cd6d88 100644 --- a/roles/system_baseline/tasks/validate.yml +++ b/roles/system_baseline/tasks/validate.yml @@ -41,6 +41,7 @@ that: - system_baseline_unattended_upgrade_origins is sequence - system_baseline_unattended_upgrade_origins is not string + - system_baseline_unattended_upgrade_origins is not mapping - system_baseline_unattended_upgrade_origins | select('string') | select('match', '^[^"\\\\\n\r]+\Z') | list | length == system_baseline_unattended_upgrade_origins | length fail_msg: >- diff --git a/roles/system_baseline/templates/unattended-upgrades-origins.j2 b/roles/system_baseline/templates/unattended-upgrades-origins.j2 index 00d55af..28f85cc 100644 --- a/roles/system_baseline/templates/unattended-upgrades-origins.j2 +++ b/roles/system_baseline/templates/unattended-upgrades-origins.j2 @@ -1,7 +1,7 @@ // Managed by Ansible (mortis.kamino.system_baseline, tasks/unattended_upgrades.yml). Do not edit: the next run overwrites it. // apt appends list entries across apt.conf.d files, so listing origins here would only widen those of 50unattended-upgrades. // This file sorts after it, clears both origin lists, and sets the only origins unattended-upgrades may install from. -// A file that sorts after this one can still add origins. +// A file that sorts after this one, and /etc/apt/apt.conf (read after apt.conf.d), can still add origins. #clear Unattended-Upgrade::Allowed-Origins; #clear Unattended-Upgrade::Origins-Pattern; Unattended-Upgrade::Origins-Pattern {