Files
Kamino/roles/system_baseline/tasks/unattended_upgrades.yml
T
Defame1297andClaude Opus 5.5 52d06204bb
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 35s
Molecule / molecule (pull_request) Successful in 1m46s
feat(system_baseline): add an update toggle and pin the pve unattended-upgrades origins
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
2026-11-14 22:11:36 +00:00

49 lines
1.7 KiB
YAML

---
- name: Apply APT periodic settings (20auto-upgrades)
become: true
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/20auto-upgrades
regexp: "^(//\\s*)?{{ item.key }}"
line: '{{ item.key }} "{{ 1 if item.value else 0 }}";'
state: present
create: true
mode: "0644"
loop: "{{ system_baseline_apt_periodic_settings | dict2items }}"
- name: Apply unattended-upgrades settings (50unattended-upgrades)
become: true
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/50unattended-upgrades
state: present
create: true
regexp: "^(//|#\\s*)?{{ item.key }}(\\s+).*"
line: '{{ item.key }} "{{ item.value }}";'
mode: "0644"
loop: "{{ system_baseline_unattended_upgrade_settings | dict2items }}"
# apt appends list entries across apt.conf.d files, so a later file cannot narrow the origins of 50unattended-upgrades by
# listing its own: the drop-in clears both origin lists first (#clear) and then sets the pinned ones. It sorts after 50.
- name: Pin the unattended-upgrades origins
become: true
ansible.builtin.template:
src: unattended-upgrades-origins.j2
dest: /etc/apt/apt.conf.d/90unattended-upgrades-origins
owner: root
group: root
mode: "0644"
when: system_baseline_unattended_upgrade_origins | length > 0
- name: Remove the origins pin when none is set
become: true
ansible.builtin.file:
path: /etc/apt/apt.conf.d/90unattended-upgrades-origins
state: absent
when: system_baseline_unattended_upgrade_origins | length == 0
- name: Validate unattended-upgrades config
become: true
ansible.builtin.command: unattended-upgrades --dry-run --debug
register: system_baseline_unattended_check
changed_when: false
failed_when: system_baseline_unattended_check.rc != 0