Review of #122. - A failed attach no longer closes the connection: the snippet does not exec tmux, it prints a line and leaves the plain shell (a client TERM without terminfo made every login fail). A clean detach still ends the connection. - The snippet acts only for an interactive shell (case $-): a login shell that is not interactive, such as `ssh -t host 'bash -lc cmd'`, is left alone. Docs corrected. - Validation anchors with \Z, so a trailing newline from a YAML block scalar is refused. It moves to validate.yml (tag always); argument_specs already covers types. - Install keys on tmux being in the resolved package list, not a second profile list. - verify.yml: the snippet does nothing without a terminal, the trailing-newline refusals, and the removal path. The vacuous pve assert is gone. - README and argument_specs: window commands start with a minimal environment (use absolute paths), zsh and fish do not read /etc/profile.d, detach ends the connection.
104 lines
3.9 KiB
YAML
104 lines
3.9 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
|
|
system_baseline_tmux_autostart: true
|
|
system_baseline_tmux_session: molecule
|
|
system_baseline_tmux_windows:
|
|
- { name: logs, command: "echo 'a b'; true" }
|
|
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"
|
|
- "'tmux' 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"
|
|
- "'tmux' 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
|