feat(system_baseline): add inputs that append packages to the profile's lists
system_baseline_essential_packages and system_baseline_remove_packages replace the whole list, and so does a list inside system_baseline_profile_overrides, so adding one package meant repeating the profile's list and keeping it in step with every release. system_baseline_extra_packages and system_baseline_extra_remove_packages (lists, default empty) append to the resolved lists. The tmux and unattended-upgrades checks read the combined list, so an extra tmux or unattended-upgrades enables the matching task like a profile package. Items must be Debian package names: a null item would have become the package "None", and apt reads a trailing minus (jq-) as a removal. A package that one input installs and another purges stops the run before any change; only overlaps that involve an extra are checked, so a consumer's own overlap between the resolved lists behaves as before. A flat input that is a plain string still counts as a one-item list. With both inputs left at their default the role behaves as before. Closes #399 Assisted-by: Claude Code:claude-sonnet-5-5
This commit is contained in:
1 parent
aa4e8c68a7
commit
d5a91520df
12 files changed
+269
-14
No files matched your search
@@ -133,11 +133,38 @@
|
||||
- [null]
|
||||
- linux-image-.*
|
||||
|
||||
# Items that are not Debian package names (whitespace, null, empty, a trailing minus that apt reads as a removal, an option, upper case, a
|
||||
# version pin), and a package that one input installs and another purges, each stop the run before any change.
|
||||
# The overlaps are: an extra install against the profile's remove list (telnet), an extra install against an extra remove, and an extra
|
||||
# remove against the profile's install list (tmux).
|
||||
- name: A bad extra package list is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Refuse each bad value
|
||||
ansible.builtin.include_tasks: tasks/refuse_extra_packages.yml
|
||||
vars:
|
||||
system_baseline_refused_case: "{{ item }}"
|
||||
loop:
|
||||
- { install: ['bad name'], expect: 'must be lists of package names' }
|
||||
- { install: [null], expect: 'must be lists of package names' }
|
||||
- { install: jq, expect: 'must be lists of package names' }
|
||||
- { remove: [''], expect: 'must be lists of package names' }
|
||||
- { install: ['jq-'], expect: 'must be lists of package names' }
|
||||
- { install: ['-y'], expect: 'must be lists of package names' }
|
||||
- { remove: ['Telnet'], expect: 'must be lists of package names' }
|
||||
- { remove: ['ed=1.0'], expect: 'must be lists of package names' }
|
||||
- { install: [telnet], expect: 'is both installed and purged' }
|
||||
- { install: [jq], remove: [jq], expect: 'is both installed and purged' }
|
||||
- { remove: [tmux], expect: 'is both installed and purged' }
|
||||
|
||||
- name: Converge the LXC profile
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_extra_packages: [jq]
|
||||
system_baseline_extra_remove_packages: [ed]
|
||||
system_baseline_tmux_autostart: true
|
||||
system_baseline_apt_daily_timeout: 1h
|
||||
system_baseline_tmux_session: molecule
|
||||
@@ -172,6 +199,8 @@
|
||||
- system_baseline_apt_upgrade == 'dist'
|
||||
- system_baseline_unattended_upgrade_origins | length == 3
|
||||
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
|
||||
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||
quiet: true
|
||||
|
||||
- name: The ubuntu_vm profile resolves
|
||||
@@ -195,6 +224,8 @@
|
||||
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
|
||||
- system_baseline_apt_upgrade == 'safe'
|
||||
- system_baseline_unattended_upgrade_origins == []
|
||||
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||
quiet: true
|
||||
|
||||
# Consumer play vars override the profile.
|
||||
@@ -224,3 +255,47 @@
|
||||
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
||||
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
||||
quiet: true
|
||||
|
||||
# The extras append to the resolved lists, whether the profile's list or a flat input supplies them, and a name that is in both is listed once.
|
||||
- name: Extra packages append to the resolved lists
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_essential_packages: [vim, curl]
|
||||
system_baseline_extra_packages: [jq, vim, unattended-upgrades]
|
||||
system_baseline_extra_remove_packages: [ed, telnet]
|
||||
tasks:
|
||||
- name: Load the role defaults
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: validate.yml
|
||||
public: true
|
||||
- name: Assert the lists the role acts on
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_install_packages == ['vim', 'curl', 'jq', 'unattended-upgrades']
|
||||
- "'ed' in __system_baseline_purge_packages"
|
||||
- __system_baseline_purge_packages | select('equalto', 'telnet') | list | length == 1
|
||||
- system_baseline_remove_packages | difference(__system_baseline_purge_packages) | length == 0
|
||||
quiet: true
|
||||
|
||||
# A flat input that is a plain string (the package module accepts one) still counts as a one-item list, with and without extras.
|
||||
- name: A flat string package list still resolves
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_essential_packages: vim
|
||||
system_baseline_extra_packages: [jq]
|
||||
tasks:
|
||||
- name: Load the role defaults
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: validate.yml
|
||||
public: true
|
||||
- name: Assert the lists the role acts on
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_install_packages == ['vim', 'jq']
|
||||
quiet: true
|
||||
Reference in new issue
Block a user