Files
Kamino/roles/system_baseline/tasks/validate.yml
T
Dragonish da3389eac1
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 21s
Molecule / molecule (pull_request) Successful in 1m30s
fix(system_baseline): keep tmux autostart from ending or swallowing logins
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.
2026-11-14 16:34:14 +00:00

37 lines
1.8 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