Adds tmux to the ubuntu_lxc and ubuntu_vm profiles and an opt-in
/etc/profile.d snippet that attaches an interactive SSH login to a tmux
session, created with configurable windows when it does not exist.
- system_baseline_tmux_autostart (default false), _session (default main)
and _windows ([{name, command}]); only ubuntu_lxc and ubuntu_vm install
the snippet, pve never does, and false removes it.
- profile.d is read only by an interactive login shell, so scp, sftp,
ssh host command and automation are unaffected. ~/.no-tmux opts a user
out. ForceCommand is not used: it would affect every session type.
- Names and commands are validated and shell-quoted; the script is
root-owned. Commands run as the logging-in user and are world-readable,
so they must hold no secret.
- Molecule converge enables it, verify checks ownership, mode, the attach
line, the quoting and sh -n.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q72rsMEKREGMfB9DH3T9mR
118 lines
5.9 KiB
YAML
118 lines
5.9 KiB
YAML
---
|
|
argument_specs:
|
|
main:
|
|
short_description: Apply the OS baseline for a system type
|
|
description:
|
|
- >-
|
|
Validates C(system_baseline_system_type), 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),
|
|
read only by an interactive login shell, so scp, sftp, C(ssh host command) and automation are unaffected. A user opts out with
|
|
C(~/.no-tmux). Only the C(ubuntu_lxc) and C(ubuntu_vm) profiles install it; with false, or on C(pve), the file is removed.
|
|
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.
|
|
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.
|