An openssh-server upgrade restarts ssh.service. With PrivateTmp=yes systemd then deletes that unit's /tmp and /var/tmp, which removes the files apt staged there while the upgrade is still running, so dpkg fails and leaves packages unpacked but not configured. The update flow now creates system_baseline_apt_tmpdir (root, mode 0700), runs the upgrade and the autoremove with TMPDIR set to it, and opens a new connection afterwards. The input is validated in the main flow and in the update entry point: absolute, no "..", not under /tmp or /var/tmp. Closes #374 Assisted-by: Claude Code:claude-sonnet-5-5
207 lines
12 KiB
YAML
207 lines
12 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 (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
|
|
journald, apt-daily timeout (when set), 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_apt_upgrade),
|
|
C(system_baseline_unattended_upgrade_settings),
|
|
C(system_baseline_unattended_upgrade_origins), 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(apt_upgrade),
|
|
C(unattended_upgrade_settings), C(unattended_upgrade_origins), C(sysctl_hardening) and C(secure_tmp_mounts).
|
|
- >-
|
|
C(unattended_upgrade_origins) is a list of unattended-upgrades C(Origins-Pattern) entries. A non-empty list is written to
|
|
C(/etc/apt/apt.conf.d/90unattended-upgrades-origins), which clears C(Unattended-Upgrade::Allowed-Origins) and
|
|
C(Unattended-Upgrade::Origins-Pattern) and sets only these entries, so they replace the distribution default instead of adding
|
|
to it. An empty or missing list removes that file and leaves the distribution default. The C(pve) profile pins Debian's
|
|
point-release and security origins; the C(ubuntu_*) profiles pin nothing. Entries may not hold a double quote, a backslash or a
|
|
line break.
|
|
- >-
|
|
C(apt_upgrade) is C(safe) or C(dist) and sets how the role upgrades packages: C(dist) runs C(apt-get dist-upgrade), which can also
|
|
remove packages that an update replaces. The C(pve) profile uses C(dist), the Ubuntu profiles C(safe).
|
|
- 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.
|
|
system_baseline_reboot_throttle:
|
|
type: int
|
|
default: 0
|
|
description:
|
|
- >-
|
|
How many hosts of a play reboot at the same time: the C(throttle) of the reboot task. 0 is no limit, as before; 1 reboots one host
|
|
at a time, for a group whose members must not be down together. A negative or non-integer value stops the run.
|
|
system_baseline_reboot_post_delay:
|
|
type: int
|
|
default: 0
|
|
description:
|
|
- >-
|
|
Seconds to wait after a rebooted host answers again, before the next host reboots (with a throttle) or the play goes on, so a
|
|
service on it can settle. 0 adds no wait, as before. A negative or non-integer value stops the run.
|
|
system_baseline_apt_daily_timeout:
|
|
type: str
|
|
default: ""
|
|
description:
|
|
- >-
|
|
Systemd time span (for example C(1h)) written as C(TimeoutStartSec) of C(apt-daily.service) in
|
|
C(/etc/systemd/system/apt-daily.service.d/10-timeout.conf), so a hung apt run is stopped. Empty leaves the host alone; clearing
|
|
the value later does not remove a file already written. A value of C(0) means no timeout to systemd.
|
|
C(apt-daily-upgrade.service) is not changed. Tag C(apt-daily-timeout).
|
|
system_baseline_apt_tmpdir:
|
|
type: str
|
|
default: /var/cache/system-baseline-apt-tmp
|
|
description:
|
|
- >-
|
|
Directory the apt upgrade and autoremove use as C(TMPDIR). It must be an absolute path made of letters, digits, C(.), C(_), C(-)
|
|
and C(/), without C(..), and not C(/tmp) or C(/var/tmp) or anything below them: an C(openssh-server) upgrade restarts
|
|
C(ssh.service), and when that unit has C(PrivateTmp=yes) systemd deletes its C(/tmp) and C(/var/tmp) while the upgrade still
|
|
needs the files apt staged there. The role creates it, owned by root with mode C(0700). An invalid value stops the run before
|
|
any change. Changing the value later does not remove the old directory.
|
|
system_baseline_unattended_upgrade_package_blacklist:
|
|
type: list
|
|
elements: str
|
|
default: []
|
|
description:
|
|
- >-
|
|
Packages unattended-upgrades must leave alone, for a host whose kernel or drivers must not change. Entries are regular
|
|
expressions matched against the package name, so C(linux-image-.*) covers every kernel image; anchor an entry (C(^name$))
|
|
when it must not match longer names too.
|
|
- >-
|
|
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
|
|
apt appends list entries across files, so these are added to those of C(50unattended-upgrades). An empty list removes the file.
|
|
An entry may not hold a double quote, a backslash or a line break.
|
|
system_baseline_update:
|
|
type: bool
|
|
default: true
|
|
description:
|
|
- >-
|
|
Run the package update (apt update, upgrade, autoremove and autoclean) in this flow. false skips it, for hosts patched by a
|
|
separate flow; the reboot check still runs, so set C(system_baseline_reboot_if_required) as well when that flow also owns
|
|
the reboot.
|
|
- The C(update) entry point does not read it.
|
|
- In check mode the main flow skips the upgrade itself (a pending update is not drift); autoremove and autoclean are still checked.
|
|
update:
|
|
short_description: Update and upgrade apt packages
|
|
description:
|
|
- Runs an apt update, upgrade, autoremove and autoclean, and nothing else.
|
|
- >-
|
|
Calling it is a request to update, so it does not read C(system_baseline_update), which only gates the main flow. In check mode it
|
|
still previews the upgrade.
|
|
- >-
|
|
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.
|
|
- >-
|
|
It creates C(system_baseline_apt_tmpdir), runs the upgrade and the autoremove with C(TMPDIR) set to it, and then opens a new
|
|
connection, so that a restart of C(ssh.service) during the upgrade does not remove the files apt needs. It reads that input
|
|
although the entry point has no argument specification of its own.
|
|
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.
|
|
system_baseline_reboot_throttle:
|
|
type: int
|
|
default: 0
|
|
description:
|
|
- Hosts that reboot at the same time (the C(throttle) of the reboot task); 0 is no limit. Checked before anything runs.
|
|
system_baseline_reboot_post_delay:
|
|
type: int
|
|
default: 0
|
|
description:
|
|
- Seconds to wait after a rebooted host answers again; 0 adds no wait. Checked before anything runs.
|