Files
Kamino/roles/system_baseline/tasks/validate.yml
T
Defame1297andClaude Opus 5.5 4d02dbbe60
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 34s
Molecule / molecule (pull_request) Successful in 1m43s
fix(system_baseline): refuse a mapping as origins and document the pin's reach
The origins check now refuses a dict, which Jinja's sequence test accepts.
The changelog states that the pve drop-in drops origins added in earlier
apt.conf.d files and names the opt-out; the README and the drop-in header
note that /etc/apt/apt.conf, read after apt.conf.d, can still add origins;
the verify play notes that the pve run rewrites the 50unattended-upgrades
keys and the ubuntu_lxc re-run restores them.

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:23:49 +00:00

52 lines
2.5 KiB
YAML

---
# Required input with no default: the role does not read a global such as system_type;
# the inventory maps it onto system_baseline_system_type.
- name: Require system_baseline_system_type
ansible.builtin.assert:
that:
- system_baseline_system_type is defined
fail_msg: >-
system_baseline_system_type is required and has no default. Set it in
the play or the inventory.
tags: always
- name: Validate system_baseline_system_type variable
ansible.builtin.assert:
that:
- system_baseline_system_type in ['ubuntu_vm', 'ubuntu_lxc', 'pve']
fail_msg: "system_baseline_system_type '{{ system_baseline_system_type }}' is invalid. Must be: ubuntu_vm, ubuntu_lxc, pve."
success_msg: "system_baseline_system_type '{{ system_baseline_system_type }}' is valid."
tags: always
# \Z, not $: Python's `$` also matches before a final newline, which a YAML block scalar would add. Not inside a double-quoted
# YAML scalar, where \Z is an invalid escape. The types and required keys are checked by meta/argument_specs.yml.
- name: Validate the tmux session and windows
ansible.builtin.assert:
that:
- system_baseline_tmux_session is match('^[A-Za-z0-9_-]{1,32}\Z')
- system_baseline_tmux_windows | map(attribute='name') | select('match', '^[A-Za-z0-9_-]{1,32}\Z') | list | length
== system_baseline_tmux_windows | length
- system_baseline_tmux_windows | map(attribute='command') | select('match', '^[^\n\r]+\Z') | list | length
== system_baseline_tmux_windows | length
fail_msg: >-
system_baseline_tmux_session must be 1-32 characters of A-Z a-z 0-9 _ - ; every system_baseline_tmux_windows entry needs
a name (same characters) and a one-line command.
quiet: true
when: system_baseline_tmux_autostart | bool
tags: always
# Each origin is written inside a double-quoted apt.conf string: a quote or a line break would end it, a backslash could escape.
- name: Validate the unattended-upgrades origins
ansible.builtin.assert:
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: >-
system_baseline_unattended_upgrade_origins must be a list of non-empty one-line strings without a double quote
or a backslash.
quiet: true
tags: always