Files
Kamino/roles/system_baseline/meta/argument_specs.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

122 lines
6.4 KiB
YAML

---
argument_specs:
main:
short_description: Apply the OS baseline for a system type
description:
- >-
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
windows, then runs the update, packages, unattended-upgrades, locale, timezone, journald,
sysctl, tmpfs, tmux and reboot task files, in that order.
- Needs gathered facts, because the reboot check reads C(ansible_os_family).
- >-
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_unattended_upgrade_settings),
C(system_baseline_sysctl_hardening) and C(system_baseline_secure_tmp_mounts) are deliberately not listed. Their defaults are
Jinja that indexes C(system_baseline_profiles) with C(system_baseline_system_type), and the argument spec is validated (templated) before
tasks/validate.yml runs, so listing them would fail on an invalid C(system_baseline_system_type) with a templating error ahead of the
role's own C(is invalid) message. They are derived from the profile and may be set directly to replace one resolved value
(a list or dict, for example C(system_baseline_remove_packages)).
options:
system_baseline_system_type:
type: str
required: true
description:
- >-
Selects the profile in C(system_baseline_profiles). One of C(ubuntu_vm), C(ubuntu_lxc) or C(pve); any other value is
refused by tasks/validate.yml.
- Not restricted by C(choices) so that the refusal keeps its own message.
system_baseline_profiles:
type: dict
description:
- >-
Policy per system type. Each profile holds C(essential_packages), C(remove_packages), C(apt_periodic_settings),
C(unattended_upgrade_settings), C(sysctl_hardening) and C(secure_tmp_mounts).
- Overriding it replaces all profiles. To change part of one profile use C(system_baseline_profile_overrides).
system_baseline_profile_overrides:
type: dict
default: {}
description:
- Sparse overrides keyed by system type and merged recursively into the active profile. Lists inside it are replaced, not merged.
system_baseline_journal_max_use:
type: str
default: 200M
description:
- Upper bound of the persistent systemd journal (journald C(SystemMaxUse), for example C(200M)).
- Written to a drop-in under C(/etc/systemd/journald.conf.d).
system_baseline_tmux_autostart:
type: bool
default: false
description:
- >-
Attach an interactive SSH login to a tmux session, creating it when it does not exist. Installs C(/etc/profile.d/tmux-autostart.sh),
which acts only for an interactive login shell with a terminal, so scp, sftp, C(ssh host command) and automation are unaffected.
Shells that do not read C(/etc/profile.d) (zsh, fish) are unaffected too. A user opts out with C(~/.no-tmux). Installed only when
C(tmux) is in the resolved package list (the C(ubuntu_lxc) and C(ubuntu_vm) profiles); with false, or without tmux, the file is
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
system_baseline_tmux_session:
type: str
default: main
description:
- Name of the session, 1 to 32 characters of C(A-Za-z0-9_-). Checked only when C(system_baseline_tmux_autostart) is true.
system_baseline_tmux_windows:
type: list
elements: dict
default: []
description:
- >-
Windows made when the session is created (a login that only re-attaches adds none), next to a plain shell. A window closes when its
command exits. The commands come from the inventory and are shell-quoted, but they run as the user who logs in, are readable by
every user on the host and show in C(ps): put no secret in one. They run with C(sh -c) from the tmux server started by the first
login, before C(~/.profile) is read, so use absolute paths for anything outside the default C(PATH).
options:
name:
type: str
required: true
description:
- Window name, 1 to 32 characters of C(A-Za-z0-9_-).
command:
type: str
required: true
description:
- One-line shell command (no line break) run in the window.
system_baseline_timezone:
type: str
default: Etc/UTC
description:
- Timezone name as reported by C(timedatectl).
system_baseline_locale:
type: str
default: en_US.UTF-8
description:
- Locale generated and set as C(LANG).
system_baseline_reboot_if_required:
type: bool
default: true
description:
- Reboot when C(/var/run/reboot-required) exists after the run.
update:
short_description: Update and upgrade apt packages
description:
- Runs an apt update, upgrade, autoremove and autoclean, and nothing else.
- >-
A supported entry point (C(tasks_from=update)) for a caller that drives its own reboot, for example a
Kubernetes node patch flow that drains the node first.
reboot:
short_description: Compute system_baseline_reboot_required and reboot when allowed
description:
- >-
Sets the C(system_baseline_reboot_required) fact from C(/var/run/reboot-required) on Debian family hosts, then reboots when
C(system_baseline_reboot_if_required) is true and the fact is true.
- >-
A supported entry point (C(tasks_from=reboot)). With C(system_baseline_reboot_if_required=false) it only computes the fact and
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
draining a node. The fact name and this behaviour are part of the role's interface.
- On a non-Debian host the fact is not set; read it with C(default(false)).
- Reads C(ansible_os_family), so facts must be gathered.
options:
system_baseline_reboot_if_required:
type: bool
default: true
description:
- Reboot when a reboot is required.