- galaxy.yml declares community.general and ansible.posix: system_baseline is the first role that calls modules outside ansible.builtin, and a consumer that installs only this Collection failed to parse the play. - The README override example set Automatic-Reboot to false, which every profile already defaults to; it now shows the opt-in. - Comment and description wording. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
98 lines
3.6 KiB
YAML
98 lines
3.6 KiB
YAML
---
|
|
- name: Refuse an unknown system_baseline_system_type
|
|
hosts: all
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Run the role with a bad system_baseline_system_type
|
|
block:
|
|
- name: Include system_baseline
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.system_baseline
|
|
vars:
|
|
system_baseline_system_type: not_a_type
|
|
- name: Unreachable when validation works
|
|
ansible.builtin.fail:
|
|
msg: system_baseline ran with an invalid system_baseline_system_type
|
|
rescue:
|
|
- name: The validation stopped the play
|
|
ansible.builtin.assert:
|
|
that: "'is invalid' in ansible_failed_result.msg | default('')"
|
|
quiet: true
|
|
|
|
- name: Converge the LXC profile
|
|
hosts: all
|
|
gather_facts: true
|
|
vars:
|
|
system_baseline_system_type: ubuntu_lxc
|
|
roles:
|
|
- role: mortis.kamino.system_baseline
|
|
|
|
# The remaining plays only load the role's defaults (validate.yml changes nothing) and assert
|
|
# the resolved inputs. They cover the profiles the converge above cannot run.
|
|
- name: The pve profile resolves
|
|
hosts: all
|
|
gather_facts: false
|
|
vars:
|
|
system_baseline_system_type: pve
|
|
tasks:
|
|
- name: Load the role defaults
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.system_baseline
|
|
tasks_from: validate.yml
|
|
public: true
|
|
- name: Assert the pve profile
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "'ufw' not in system_baseline_essential_packages"
|
|
- "'unattended-upgrades' in system_baseline_essential_packages"
|
|
- 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']
|
|
quiet: true
|
|
|
|
- name: The ubuntu_vm profile resolves
|
|
hosts: all
|
|
gather_facts: false
|
|
vars:
|
|
system_baseline_system_type: ubuntu_vm
|
|
tasks:
|
|
- name: Load the role defaults
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.system_baseline
|
|
tasks_from: validate.yml
|
|
public: true
|
|
- name: Assert the ubuntu_vm profile
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
|
- 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
|
|
quiet: true
|
|
|
|
# Consumer play vars override the profile.
|
|
- name: Consumer overrides win over the profile
|
|
hosts: all
|
|
gather_facts: false
|
|
vars:
|
|
system_baseline_system_type: ubuntu_vm
|
|
system_baseline_remove_packages: [telnet]
|
|
system_baseline_profile_overrides:
|
|
ubuntu_vm:
|
|
unattended_upgrade_settings:
|
|
"Unattended-Upgrade::Automatic-Reboot": true
|
|
tasks:
|
|
- name: Load the role defaults
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.system_baseline
|
|
tasks_from: validate.yml
|
|
public: true
|
|
- name: Assert the overrides
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_baseline_remove_packages == ['telnet']
|
|
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == true
|
|
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
|
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
|
quiet: true
|