Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a2060bd31 | ||
|
|
40e3b39990 | ||
|
|
e1a46fcdb1 | ||
|
|
d5a91520df | ||
|
|
a659e83e6b |
No files matched your search
@@ -4,6 +4,24 @@ mortis.kamino Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v3.1.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true, enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with ``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a tailnet.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd unit does not exist yet.
|
||||||
|
- docker - Do not fail under ``--check`` on a host where the Docker repository and packages are not installed yet.
|
||||||
|
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
|
||||||
|
- gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the systemd unit does not exist yet.
|
||||||
|
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
|
||||||
|
- user_management - Do not fail under ``--check`` when a managed user does not exist yet.
|
||||||
|
|
||||||
v3.0.0
|
v3.0.0
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
|||||||
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
|
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
|
||||||
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
||||||
|
|
||||||
Status: roles arrive in waves. Release 3.0.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
Status: roles arrive in waves. Release 3.1.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
||||||
|
|
||||||
## Consuming
|
## Consuming
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
|
|||||||
collections:
|
collections:
|
||||||
- name: https://git.rkdr.net/mortis/kamino.git
|
- name: https://git.rkdr.net/mortis/kamino.git
|
||||||
type: git
|
type: git
|
||||||
version: v3.0.0
|
version: v3.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ objects:
|
|||||||
description: Harden systemd for a system type
|
description: Harden systemd for a system type
|
||||||
name: systemd_hardening
|
name: systemd_hardening
|
||||||
version_added: null
|
version_added: null
|
||||||
|
tailscale:
|
||||||
|
description: Install Tailscale and bring the node up
|
||||||
|
name: tailscale
|
||||||
|
version_added: null
|
||||||
traefik:
|
traefik:
|
||||||
description: Install, configure, update or remove Traefik as a systemd binary
|
description: Install, configure, update or remove Traefik as a systemd binary
|
||||||
name: traefik
|
name: traefik
|
||||||
@@ -81,4 +85,4 @@ plugins:
|
|||||||
strategy: {}
|
strategy: {}
|
||||||
test: {}
|
test: {}
|
||||||
vars: {}
|
vars: {}
|
||||||
version: 3.0.0
|
version: 3.1.0
|
||||||
@@ -446,3 +446,31 @@ releases:
|
|||||||
- 133-drop-jammy-and-ubuntu-all.yml
|
- 133-drop-jammy-and-ubuntu-all.yml
|
||||||
- 133-ubuntu-2604.yml
|
- 133-ubuntu-2604.yml
|
||||||
release_date: '2026-11-26'
|
release_date: '2026-11-26'
|
||||||
|
3.1.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared
|
||||||
|
account or systemd unit does not exist yet.
|
||||||
|
- docker - Do not fail under ``--check`` on a host where the Docker repository
|
||||||
|
and packages are not installed yet.
|
||||||
|
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed
|
||||||
|
yet.
|
||||||
|
- gitea_runner - Do not fail under ``--check`` on a host where the runner account,
|
||||||
|
Docker or the systemd unit does not exist yet.
|
||||||
|
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed
|
||||||
|
yet.
|
||||||
|
- user_management - Do not fail under ``--check`` when a managed user does not
|
||||||
|
exist yet.
|
||||||
|
minor_changes:
|
||||||
|
- tailscale - New role. Installs Tailscale from the upstream APT repository
|
||||||
|
with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in
|
||||||
|
the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
|
||||||
|
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs
|
||||||
|
``tailscale up`` with ``tailscale_auth_key`` while the node is not Running;
|
||||||
|
it can also update to the APT candidate version and remove or purge. Declares
|
||||||
|
Ubuntu noble and resolute; the molecule scenario installs the real package
|
||||||
|
but does not join a tailnet.
|
||||||
|
fragments:
|
||||||
|
- 134-check-mode.yml
|
||||||
|
- tailscale-role.yml
|
||||||
|
release_date: '2026-11-26'
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
bugfixes:
|
|
||||||
- >-
|
|
||||||
cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd
|
|
||||||
unit does not exist yet.
|
|
||||||
- >-
|
|
||||||
docker - Do not fail under ``--check`` on a host where the Docker repository and packages are
|
|
||||||
not installed yet.
|
|
||||||
- >-
|
|
||||||
gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
|
|
||||||
- >-
|
|
||||||
gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the
|
|
||||||
systemd unit does not exist yet.
|
|
||||||
- >-
|
|
||||||
traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
|
|
||||||
- >-
|
|
||||||
user_management - Do not fail under ``--check`` when a managed user does not exist yet.
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- >-
|
||||||
|
system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages`` (lists, default empty), which
|
||||||
|
append to the resolved package lists, where setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages``
|
||||||
|
replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades`` enables the matching task like a profile package.
|
||||||
|
A package that one input installs and another purges stops the run before any change. With both inputs left at their default the
|
||||||
|
role behaves as before.
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- >-
|
|
||||||
system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump`` (default ``false``). With ``true`` on the ``pve`` system type,
|
|
||||||
the main flow and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks --source active`` lists a
|
|
||||||
``vzdump`` task, and say so. With the default no ``pvesh`` command runs and the upgrade is unchanged.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- >-
|
|
||||||
tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256,
|
|
||||||
sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
|
|
||||||
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with
|
|
||||||
``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove
|
|
||||||
or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a
|
|
||||||
tailnet.
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
namespace: mortis
|
namespace: mortis
|
||||||
name: kamino
|
name: kamino
|
||||||
version: 3.0.0
|
version: 3.1.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Defame1297
|
- Defame1297
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ templating error instead of the role's own message.
|
|||||||
| `system_baseline_profile` | derived | no | Active profile after overrides |
|
| `system_baseline_profile` | derived | no | Active profile after overrides |
|
||||||
| `system_baseline_essential_packages` | from profile | no | Packages to install |
|
| `system_baseline_essential_packages` | from profile | no | Packages to install |
|
||||||
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
|
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
|
||||||
|
| `system_baseline_extra_packages` | `[]` | no | Packages to install in addition to the resolved list; appends, see "Adding packages to a profile" |
|
||||||
|
| `system_baseline_extra_remove_packages` | `[]` | no | Packages to purge in addition to the resolved list; appends |
|
||||||
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
||||||
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
|
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
|
||||||
| `system_baseline_skip_upgrade_during_vzdump` | `false` | no | `pve` only: skip the apt upgrade while a vzdump backup is running on the node (see "Skipping the upgrade during a backup") |
|
|
||||||
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
||||||
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
|
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
|
||||||
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
|
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
|
||||||
@@ -131,8 +132,8 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
|||||||
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
|
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
|
||||||
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
|
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
|
||||||
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
|
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
|
||||||
|
- Converge refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges, then applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
|
||||||
- Converge also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
- Converge also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||||
- Verify runs the `update` entry point in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`), and asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
|
|
||||||
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
|
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
|
||||||
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
|
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
|
||||||
|
|
||||||
@@ -147,9 +148,22 @@ Not covered: Molecule skips `sysctl`, `secure_tmp`, `update` and `timezone` (no
|
|||||||
- Policy lives in defaults, not `vars/`, so group_vars and host_vars can override it.
|
- Policy lives in defaults, not `vars/`, so group_vars and host_vars can override it.
|
||||||
- `no_log` is not used: the role handles no secrets.
|
- `no_log` is not used: the role handles no secrets.
|
||||||
|
|
||||||
|
### Adding packages to a profile
|
||||||
|
|
||||||
|
`system_baseline_essential_packages` and `system_baseline_remove_packages` replace the profile's whole list, and so does a list inside `system_baseline_profile_overrides`. To add or drop a few packages and keep the profile's own, use the two extra lists, which append:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
system_baseline_extra_remove_packages: [telnet]
|
||||||
|
```
|
||||||
|
|
||||||
|
- Each item is a Debian package name: lower-case letters, digits, `+`, `-` and `.`, two or more characters, starting with a letter or digit and not ending in `-` (apt reads a trailing minus as a removal). Anything else stops the run. Duplicates of the profile list are harmless.
|
||||||
|
- An extra counts wherever the role looks for a package in the list: an extra `tmux` enables the tmux snippet and an extra `unattended-upgrades` the unattended-upgrades tasks, as a profile package does.
|
||||||
|
- A package that one input installs and another purges stops the run before any change: `system_baseline_extra_packages` against `system_baseline_remove_packages` or `system_baseline_extra_remove_packages`, and `system_baseline_extra_remove_packages` against `system_baseline_essential_packages`. The resolved lists are not checked against each other, so a consumer's own overlap there behaves as before.
|
||||||
|
|
||||||
### tmux on SSH login
|
### tmux on SSH login
|
||||||
|
|
||||||
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; `pve` never gets the snippet.
|
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; the `pve` profile has none, so it gets the snippet only if `system_baseline_extra_packages` adds `tmux`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
system_baseline_tmux_autostart: true
|
system_baseline_tmux_autostart: true
|
||||||
@@ -159,7 +173,7 @@ system_baseline_tmux_windows:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- It is `/etc/profile.d/tmux-autostart.sh`. Every login shell reads that directory, so the snippet itself acts only for an interactive shell (`case $-`) with a terminal and an SSH connection, outside tmux, and without `~/.no-tmux`. `scp`, `sftp`, `ssh host command`, Ansible and `ssh -t host 'bash -lc cmd'` never trigger it. sshd's `ForceCommand` is not used: it applies to every session type and a broken tmux would lock all of them out. Users whose login shell is zsh or fish are not affected, because those shells do not read `/etc/profile.d`.
|
- It is `/etc/profile.d/tmux-autostart.sh`. Every login shell reads that directory, so the snippet itself acts only for an interactive shell (`case $-`) with a terminal and an SSH connection, outside tmux, and without `~/.no-tmux`. `scp`, `sftp`, `ssh host command`, Ansible and `ssh -t host 'bash -lc cmd'` never trigger it. sshd's `ForceCommand` is not used: it applies to every session type and a broken tmux would lock all of them out. Users whose login shell is zsh or fish are not affected, because those shells do not read `/etc/profile.d`.
|
||||||
- The snippet is installed when autostart is on and the resolved package list contains `tmux` (the `ubuntu_lxc` and `ubuntu_vm` profiles). If you override `system_baseline_essential_packages` without it, nothing is installed.
|
- The snippet is installed when autostart is on and the packages to install contain `tmux`: the `ubuntu_lxc` and `ubuntu_vm` profiles have it, and `system_baseline_extra_packages` can add it. If you override `system_baseline_essential_packages` without it and add no extra `tmux`, nothing is installed.
|
||||||
- A failed attach (for example a client `TERM` such as `xterm-kitty` or `wezterm` without a terminfo entry on the host) prints a line and leaves a plain shell. Detaching (`Ctrl-b d`) ends the SSH connection, as `exit` would.
|
- A failed attach (for example a client `TERM` such as `xterm-kitty` or `wezterm` without a terminfo entry on the host) prints a line and leaves a plain shell. Detaching (`Ctrl-b d`) ends the SSH connection, as `exit` would.
|
||||||
- Turn it off for one login with `ssh -t host bash` (a non-login shell does not read `/etc/profile.d`), for one user with `touch ~/.no-tmux`, and for the host by setting the variable to `false` and running the role (it removes the snippet).
|
- Turn it off for one login with `ssh -t host bash` (a non-login shell does not read `/etc/profile.d`), for one user with `touch ~/.no-tmux`, and for the host by setting the variable to `false` and running the role (it removes the snippet).
|
||||||
- The windows are made when the session is created; a login that re-attaches adds none, so a change applies from the next new session. A window closes when its command exits. A window command runs with `sh -c` from the tmux server of the first login, before `~/.profile` is read, so it does not see `~/.local/bin` and other additions made there: use absolute paths.
|
- The windows are made when the session is created; a login that re-attaches adds none, so a change applies from the next new session. A window closes when its command exits. A window command runs with `sh -c` from the tmux server of the first login, before `~/.profile` is read, so it does not see `~/.local/bin` and other additions made there: use absolute paths.
|
||||||
@@ -197,15 +211,6 @@ The profile key `apt_upgrade` (`safe` or `dist`, resolved to `system_baseline_ap
|
|||||||
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
|
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
|
||||||
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
|
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
|
||||||
|
|
||||||
### Skipping the upgrade during a backup
|
|
||||||
|
|
||||||
An upgrade of a Proxmox node can restart Proxmox services while a backup holds a snapshot of a guest. With `system_baseline_skip_upgrade_during_vzdump: true` and `system_baseline_system_type: pve`, the role runs `pvesh get /nodes/localhost/tasks --source active --limit 0` before the upgrade (`--source active` lists the running tasks; the default, `archive`, holds only finished ones). When one of the listed tasks has the type `vzdump` and no `endtime`, the upgrade is skipped and a message says why; autoremove, autoclean and the reboot check still run, and the role does not wait for the backup, so run it again afterwards.
|
|
||||||
|
|
||||||
- Off by default. With `false`, or on any other system type, no `pvesh` command runs.
|
|
||||||
- The `update` entry point reads the input as well. In check mode the main flow skips the upgrade itself, so it does not ask for the tasks; the entry point previews the upgrade and so asks.
|
|
||||||
- `localhost` is the node's own alias in the Proxmox API, so the role needs neither a node name nor gathered facts.
|
|
||||||
- A `pvesh` answer that is not a JSON list stops the run, instead of upgrading on a guess.
|
|
||||||
|
|
||||||
### Apt scratch directory
|
### Apt scratch directory
|
||||||
|
|
||||||
The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow 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, so that later tasks get a fresh private `/tmp`.
|
The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow 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, so that later tasks get a fresh private `/tmp`.
|
||||||
|
|||||||
@@ -18,13 +18,11 @@ system_baseline_apt_tmpdir: /var/cache/system-baseline-apt-tmp
|
|||||||
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
|
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
|
||||||
# operator-run flow; the tasks_from: update entry point does not read it.
|
# operator-run flow; the tasks_from: update entry point does not read it.
|
||||||
system_baseline_update: true
|
system_baseline_update: true
|
||||||
# Skip the apt upgrade while a vzdump backup is running on the Proxmox node (tasks/update.yml). Only for system_baseline_system_type pve;
|
|
||||||
# both the main flow and the tasks_from: update entry point read it. Off by default.
|
|
||||||
system_baseline_skip_upgrade_during_vzdump: false
|
|
||||||
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it.
|
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it.
|
||||||
system_baseline_journal_max_use: 200M
|
system_baseline_journal_max_use: 200M
|
||||||
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
|
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
|
||||||
# Only the ubuntu_lxc and ubuntu_vm profiles honour it; pve never installs the snippet.
|
# Installed only when tmux is among the packages to install: the ubuntu_lxc and ubuntu_vm profiles have it, the pve profile has none unless
|
||||||
|
# system_baseline_extra_packages adds it.
|
||||||
system_baseline_tmux_autostart: false
|
system_baseline_tmux_autostart: false
|
||||||
# Name of the session an SSH login attaches to.
|
# Name of the session an SSH login attaches to.
|
||||||
system_baseline_tmux_session: main
|
system_baseline_tmux_session: main
|
||||||
@@ -249,6 +247,19 @@ system_baseline_profile: >-
|
|||||||
# Inputs the tasks read
|
# Inputs the tasks read
|
||||||
system_baseline_essential_packages: "{{ system_baseline_profile.essential_packages }}"
|
system_baseline_essential_packages: "{{ system_baseline_profile.essential_packages }}"
|
||||||
system_baseline_remove_packages: "{{ system_baseline_profile.remove_packages }}"
|
system_baseline_remove_packages: "{{ system_baseline_profile.remove_packages }}"
|
||||||
|
# Packages installed and purged in addition to the two resolved lists above. They append: a flat essential or remove input replaces its
|
||||||
|
# list, so adding one package that way means repeating the whole profile list.
|
||||||
|
system_baseline_extra_packages: []
|
||||||
|
system_baseline_extra_remove_packages: []
|
||||||
|
# What the role acts on: each resolved list plus its extras, without duplicates. Internal, read by tasks/packages.yml, tasks/tmux.yml and
|
||||||
|
# tasks/main.yml, so that an extra `tmux` or `unattended-upgrades` enables the matching task like a profile package does.
|
||||||
|
# A flat input that is a plain string (`system_baseline_essential_packages: vim`, which the package module accepts) counts as a one-item list.
|
||||||
|
__system_baseline_install_packages: >-
|
||||||
|
{{ (([system_baseline_essential_packages] if system_baseline_essential_packages is string else system_baseline_essential_packages)
|
||||||
|
+ system_baseline_extra_packages) | unique | list }}
|
||||||
|
__system_baseline_purge_packages: >-
|
||||||
|
{{ (([system_baseline_remove_packages] if system_baseline_remove_packages is string else system_baseline_remove_packages)
|
||||||
|
+ system_baseline_extra_remove_packages) | unique | list }}
|
||||||
system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_settings }}"
|
system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_settings }}"
|
||||||
# safe or dist (see the profiles). Guarded: the tasks_from: update entry point needs no system_baseline_system_type, and without one it
|
# safe or dist (see the profiles). Guarded: the tasks_from: update entry point needs no system_baseline_system_type, and without one it
|
||||||
# stays on a safe upgrade instead of failing on the profile lookup. default('safe'): a system_baseline_profiles written before this key
|
# stays on a safe upgrade instead of failing on the profile lookup. default('safe'): a system_baseline_profiles written before this key
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ argument_specs:
|
|||||||
Attach an interactive SSH login to a tmux session, creating it when it does not exist. Installs C(/etc/profile.d/tmux-autostart.sh),
|
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.
|
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
|
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
|
C(tmux) is among the packages to install (the C(ubuntu_lxc) and C(ubuntu_vm) profiles have it, and C(system_baseline_extra_packages)
|
||||||
|
can add it to any profile, C(pve) included); with false, or without tmux, the file is
|
||||||
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
|
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
|
||||||
system_baseline_tmux_session:
|
system_baseline_tmux_session:
|
||||||
type: str
|
type: str
|
||||||
@@ -152,6 +153,27 @@ argument_specs:
|
|||||||
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
|
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.
|
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.
|
An entry may not hold a double quote, a backslash or a line break.
|
||||||
|
system_baseline_extra_packages:
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
Packages installed in addition to the resolved C(system_baseline_essential_packages). The list appends: setting
|
||||||
|
C(system_baseline_essential_packages) itself replaces the profile's list. A package named here also counts for the checks that read
|
||||||
|
the package list (C(tmux) for the tmux snippet, C(unattended-upgrades) for the unattended-upgrades tasks). Each item is a Debian
|
||||||
|
package name: lower-case letters, digits, C(+), C(-) and C(.), two or more characters, starting with a letter or digit and not
|
||||||
|
ending in C(-) (apt reads a trailing minus as a removal). A package that is also in C(system_baseline_remove_packages) or
|
||||||
|
C(system_baseline_extra_remove_packages) stops the run before any change.
|
||||||
|
system_baseline_extra_remove_packages:
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
Packages purged, when installed, in addition to the resolved C(system_baseline_remove_packages). The list appends. Each item is a
|
||||||
|
Debian package name, as for C(system_baseline_extra_packages). A package that is also in C(system_baseline_essential_packages)
|
||||||
|
stops the run before any change.
|
||||||
system_baseline_update:
|
system_baseline_update:
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
@@ -162,18 +184,6 @@ argument_specs:
|
|||||||
the reboot.
|
the reboot.
|
||||||
- The C(update) entry point does not read it.
|
- 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.
|
- In check mode the main flow skips the upgrade itself (a pending update is not drift); autoremove and autoclean are still checked.
|
||||||
system_baseline_skip_upgrade_during_vzdump:
|
|
||||||
type: bool
|
|
||||||
default: false
|
|
||||||
description:
|
|
||||||
- >-
|
|
||||||
Skip the apt upgrade while a vzdump backup is running on the Proxmox node. Acts only when C(system_baseline_system_type) is
|
|
||||||
C(pve): the role runs C(pvesh get /nodes/localhost/tasks --source active), and a C(vzdump) task in that list is a running backup.
|
|
||||||
The upgrade is then skipped with a message, and the rest of the flow (autoremove, the reboot check) goes on. It does not wait for
|
|
||||||
the backup. With false, or on any other system type, no C(pvesh) command runs.
|
|
||||||
- >-
|
|
||||||
The C(update) entry point reads it too, and a C(pvesh) answer that is not a JSON list fails the run instead of upgrading. In check mode the
|
|
||||||
main flow skips the upgrade itself, so it does not ask for the tasks.
|
|
||||||
update:
|
update:
|
||||||
short_description: Update and upgrade apt packages
|
short_description: Update and upgrade apt packages
|
||||||
description:
|
description:
|
||||||
@@ -188,9 +198,6 @@ argument_specs:
|
|||||||
It creates C(system_baseline_apt_tmpdir), runs the upgrade and the autoremove with C(TMPDIR) set to it, and then opens a new
|
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
|
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.
|
although the entry point has no argument specification of its own.
|
||||||
- >-
|
|
||||||
It also reads C(system_baseline_skip_upgrade_during_vzdump): with true on C(system_baseline_system_type) C(pve) it skips the upgrade while
|
|
||||||
a vzdump backup is running.
|
|
||||||
reboot:
|
reboot:
|
||||||
short_description: Compute system_baseline_reboot_required and reboot when allowed
|
short_description: Compute system_baseline_reboot_required and reboot when allowed
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -133,11 +133,38 @@
|
|||||||
- [null]
|
- [null]
|
||||||
- linux-image-.*
|
- linux-image-.*
|
||||||
|
|
||||||
|
# Items that are not Debian package names (whitespace, null, empty, a trailing minus that apt reads as a removal, an option, upper case, a
|
||||||
|
# version pin), and a package that one input installs and another purges, each stop the run before any change.
|
||||||
|
# The overlaps are: an extra install against the profile's remove list (telnet), an extra install against an extra remove, and an extra
|
||||||
|
# remove against the profile's install list (tmux).
|
||||||
|
- name: A bad extra package list is refused
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Refuse each bad value
|
||||||
|
ansible.builtin.include_tasks: tasks/refuse_extra_packages.yml
|
||||||
|
vars:
|
||||||
|
system_baseline_refused_case: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- { install: ['bad name'], expect: 'must be lists of package names' }
|
||||||
|
- { install: [null], expect: 'must be lists of package names' }
|
||||||
|
- { install: jq, expect: 'must be lists of package names' }
|
||||||
|
- { remove: [''], expect: 'must be lists of package names' }
|
||||||
|
- { install: ['jq-'], expect: 'must be lists of package names' }
|
||||||
|
- { install: ['-y'], expect: 'must be lists of package names' }
|
||||||
|
- { remove: ['Telnet'], expect: 'must be lists of package names' }
|
||||||
|
- { remove: ['ed=1.0'], expect: 'must be lists of package names' }
|
||||||
|
- { install: [telnet], expect: 'is both installed and purged' }
|
||||||
|
- { install: [jq], remove: [jq], expect: 'is both installed and purged' }
|
||||||
|
- { remove: [tmux], expect: 'is both installed and purged' }
|
||||||
|
|
||||||
- name: Converge the LXC profile
|
- name: Converge the LXC profile
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
vars:
|
vars:
|
||||||
system_baseline_system_type: ubuntu_lxc
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
system_baseline_extra_remove_packages: [ed]
|
||||||
system_baseline_tmux_autostart: true
|
system_baseline_tmux_autostart: true
|
||||||
system_baseline_apt_daily_timeout: 1h
|
system_baseline_apt_daily_timeout: 1h
|
||||||
system_baseline_tmux_session: molecule
|
system_baseline_tmux_session: molecule
|
||||||
@@ -172,6 +199,8 @@
|
|||||||
- system_baseline_apt_upgrade == 'dist'
|
- system_baseline_apt_upgrade == 'dist'
|
||||||
- system_baseline_unattended_upgrade_origins | length == 3
|
- system_baseline_unattended_upgrade_origins | length == 3
|
||||||
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
|
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
|
||||||
|
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||||
|
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: The ubuntu_vm profile resolves
|
- name: The ubuntu_vm profile resolves
|
||||||
@@ -195,6 +224,8 @@
|
|||||||
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
|
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
|
||||||
- system_baseline_apt_upgrade == 'safe'
|
- system_baseline_apt_upgrade == 'safe'
|
||||||
- system_baseline_unattended_upgrade_origins == []
|
- system_baseline_unattended_upgrade_origins == []
|
||||||
|
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||||
|
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
# Consumer play vars override the profile.
|
# Consumer play vars override the profile.
|
||||||
@@ -224,3 +255,47 @@
|
|||||||
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
||||||
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# The extras append to the resolved lists, whether the profile's list or a flat input supplies them, and a name that is in both is listed once.
|
||||||
|
- name: Extra packages append to the resolved lists
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_essential_packages: [vim, curl]
|
||||||
|
system_baseline_extra_packages: [jq, vim, unattended-upgrades]
|
||||||
|
system_baseline_extra_remove_packages: [ed, telnet]
|
||||||
|
tasks:
|
||||||
|
- name: Load the role defaults
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: validate.yml
|
||||||
|
public: true
|
||||||
|
- name: Assert the lists the role acts on
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- __system_baseline_install_packages == ['vim', 'curl', 'jq', 'unattended-upgrades']
|
||||||
|
- "'ed' in __system_baseline_purge_packages"
|
||||||
|
- __system_baseline_purge_packages | select('equalto', 'telnet') | list | length == 1
|
||||||
|
- system_baseline_remove_packages | difference(__system_baseline_purge_packages) | length == 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
# A flat input that is a plain string (the package module accepts one) still counts as a one-item list, with and without extras.
|
||||||
|
- name: A flat string package list still resolves
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_essential_packages: vim
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
tasks:
|
||||||
|
- name: Load the role defaults
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: validate.yml
|
||||||
|
public: true
|
||||||
|
- name: Assert the lists the role acts on
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- __system_baseline_install_packages == ['vim', 'jq']
|
||||||
|
quiet: true
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
---
|
---
|
||||||
# A package the role must remove, and the locales tool the role assumes exists
|
# A package the role must remove, and the locales tool the role assumes exists
|
||||||
# (it does on a stock Ubuntu host).
|
# (it does on a stock Ubuntu host). jq (system_baseline_extra_packages) must be absent, so that the role is what installs it, and ed
|
||||||
|
# (system_baseline_extra_remove_packages, on no profile list) must be present, so that the role is what purges it.
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Install a package on the role's remove list and locale-gen
|
- name: Install a package on the role's remove list and locale-gen
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: [telnet, locales]
|
name: [telnet, locales, ed]
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Make sure jq is not installed
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: jq
|
||||||
|
state: absent
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# One refusal per call: the role must stop on validation, before it changes anything, with a message that names the inputs.
|
||||||
|
# The case comes in as system_baseline_refused_case: {install, remove, expect}.
|
||||||
|
- name: Run the role with a bad extra package list
|
||||||
|
block:
|
||||||
|
- name: Include system_baseline
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_extra_packages: "{{ system_baseline_refused_case.install | default([]) }}"
|
||||||
|
system_baseline_extra_remove_packages: "{{ system_baseline_refused_case.remove | default([]) }}"
|
||||||
|
- name: Unreachable when validation works
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: system_baseline ran with a bad extra package list
|
||||||
|
rescue:
|
||||||
|
- name: The validation stopped the play with the expected message
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: system_baseline_refused_case.expect in ansible_failed_result.msg | default('')
|
||||||
|
fail_msg: "Expected '{{ system_baseline_refused_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
|
||||||
|
quiet: true
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
|
|
||||||
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
|
|
||||||
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
|
|
||||||
- name: Write the pvesh stub
|
|
||||||
check_mode: false
|
|
||||||
ansible.builtin.copy:
|
|
||||||
dest: /usr/local/bin/pvesh
|
|
||||||
mode: "0755"
|
|
||||||
content: |
|
|
||||||
#!/bin/sh
|
|
||||||
echo "$*" >> /var/tmp/pvesh-calls
|
|
||||||
cat <<'JSON'
|
|
||||||
{{ system_baseline_case.answer | to_json }}
|
|
||||||
JSON
|
|
||||||
|
|
||||||
- name: Create the apt scratch directory, which a check mode run does not
|
|
||||||
check_mode: false
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /var/cache/system-baseline-apt-tmp
|
|
||||||
state: directory
|
|
||||||
mode: "0700"
|
|
||||||
|
|
||||||
- name: Forget earlier calls
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /var/tmp/pvesh-calls
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Run the update entry point in check mode
|
|
||||||
check_mode: true
|
|
||||||
block:
|
|
||||||
- name: Include system_baseline, tasks_from update
|
|
||||||
ansible.builtin.include_role:
|
|
||||||
name: mortis.kamino.system_baseline
|
|
||||||
tasks_from: update
|
|
||||||
vars:
|
|
||||||
system_baseline_system_type: "{{ system_baseline_case.type }}"
|
|
||||||
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
|
|
||||||
|
|
||||||
- name: Read the recorded pvesh calls
|
|
||||||
ansible.builtin.slurp:
|
|
||||||
src: /var/tmp/pvesh-calls
|
|
||||||
register: system_baseline_case_calls
|
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: The guard decided as the case expects, and pvesh was asked only when it should be
|
|
||||||
ansible.builtin.assert:
|
|
||||||
that:
|
|
||||||
- __system_baseline_vzdump_running == system_baseline_case.running
|
|
||||||
- (system_baseline_case_calls.content is defined) == system_baseline_case.asked
|
|
||||||
- not system_baseline_case.asked or
|
|
||||||
"get /nodes/localhost/tasks --source active --limit 0 --output-format json" in (system_baseline_case_calls.content | b64decode)
|
|
||||||
quiet: true
|
|
||||||
|
|
||||||
- name: Remove the pvesh stub and its record
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
loop:
|
|
||||||
- /usr/local/bin/pvesh
|
|
||||||
- /var/tmp/pvesh-calls
|
|
||||||
@@ -17,6 +17,16 @@
|
|||||||
- "'telnet' not in ansible_facts.packages"
|
- "'telnet' not in ansible_facts.packages"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# jq was absent before the role ran and is on no profile list: the extra list installed it, and the profile's own packages (tmux,
|
||||||
|
# curl above) are still there. ed was present and is on no profile list: the extra remove list purged it.
|
||||||
|
- name: The extra packages were installed and the extra removal purged
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'jq' in ansible_facts.packages"
|
||||||
|
- "'curl' in ansible_facts.packages"
|
||||||
|
- "'ed' not in ansible_facts.packages"
|
||||||
|
quiet: true
|
||||||
|
|
||||||
- name: Read the journald drop-in
|
- name: Read the journald drop-in
|
||||||
ansible.builtin.slurp:
|
ansible.builtin.slurp:
|
||||||
src: /etc/systemd/journald.conf.d/50-system-baseline.conf
|
src: /etc/systemd/journald.conf.d/50-system-baseline.conf
|
||||||
@@ -254,6 +264,51 @@
|
|||||||
that: not system_baseline_verify_removed.stat.exists
|
that: not system_baseline_verify_removed.stat.exists
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# An extra tmux counts like a profile tmux: a flat package list without it installs no snippet, the same list plus the extra does.
|
||||||
|
- name: Run the tmux tasks with a flat package list that lacks tmux
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: true
|
||||||
|
system_baseline_essential_packages: [vim]
|
||||||
|
|
||||||
|
- name: Stat the snippet without the extra
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
|
register: system_baseline_verify_no_extra
|
||||||
|
|
||||||
|
- name: Run the tmux tasks with tmux as an extra package
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: true
|
||||||
|
system_baseline_essential_packages: [vim]
|
||||||
|
system_baseline_extra_packages: [tmux]
|
||||||
|
|
||||||
|
- name: Stat the snippet with the extra
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
|
register: system_baseline_verify_with_extra
|
||||||
|
|
||||||
|
- name: Only the extra tmux installs the snippet
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- not system_baseline_verify_no_extra.stat.exists
|
||||||
|
- system_baseline_verify_with_extra.stat.exists
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Remove the snippet again
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: false
|
||||||
|
|
||||||
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
|
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
|
||||||
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
|
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
|
||||||
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
|
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
|
||||||
@@ -395,22 +450,3 @@
|
|||||||
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
||||||
quiet: true
|
quiet: true
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
# The vzdump guard (system_baseline_skip_upgrade_during_vzdump): a running backup is a vzdump task without an endtime. With the input off, or on
|
|
||||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
|
|
||||||
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
|
|
||||||
hosts: all
|
|
||||||
gather_facts: false
|
|
||||||
tasks:
|
|
||||||
- name: Run each case
|
|
||||||
ansible.builtin.include_tasks: tasks/vzdump_guard_case.yml
|
|
||||||
vars:
|
|
||||||
system_baseline_case: "{{ item }}"
|
|
||||||
loop:
|
|
||||||
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
|
||||||
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}, {type: qmstart, upid: b, starttime: 1}]}
|
|
||||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: vzdump, upid: a, starttime: 1, endtime: 2}]}
|
|
||||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: qmstart, upid: b, starttime: 1}]}
|
|
||||||
- {type: pve, input: true, running: false, asked: true, answer: []}
|
|
||||||
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
|
||||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
- name: Configure unattended-upgrades
|
- name: Configure unattended-upgrades
|
||||||
ansible.builtin.import_tasks: unattended_upgrades.yml
|
ansible.builtin.import_tasks: unattended_upgrades.yml
|
||||||
when: "'unattended-upgrades' in system_baseline_essential_packages"
|
when: "'unattended-upgrades' in __system_baseline_install_packages"
|
||||||
tags: unattended-upgrades
|
tags: unattended-upgrades
|
||||||
|
|
||||||
- name: Set locale
|
- name: Set locale
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Install essential packages
|
- name: Install essential packages
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: "{{ system_baseline_essential_packages }}"
|
name: "{{ __system_baseline_install_packages }}"
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
become: true
|
become: true
|
||||||
@@ -16,6 +16,6 @@
|
|||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
purge: true
|
purge: true
|
||||||
loop: "{{ system_baseline_remove_packages }}"
|
loop: "{{ __system_baseline_purge_packages }}"
|
||||||
when: item in ansible_facts.packages
|
when: item in ansible_facts.packages
|
||||||
become: true
|
become: true
|
||||||
@@ -4,9 +4,10 @@
|
|||||||
# connection, so scp, sftp, `ssh host command` and automation never trigger it.
|
# connection, so scp, sftp, `ssh host command` and automation never trigger it.
|
||||||
# sshd's ForceCommand is deliberately not used: it applies to every session type and a broken tmux would lock out all of them.
|
# sshd's ForceCommand is deliberately not used: it applies to every session type and a broken tmux would lock out all of them.
|
||||||
#
|
#
|
||||||
# Installed when autostart is on and the resolved package list holds tmux (the ubuntu_lxc and ubuntu_vm profiles); the inputs are
|
# Installed when autostart is on and the packages to install hold tmux (the ubuntu_lxc and ubuntu_vm profiles, or
|
||||||
# checked in validate.yml. Security: the session name, window names and commands are role inputs (inventory), never read from a user
|
# system_baseline_extra_packages); the inputs are checked in validate.yml. Security: the session name, window names and commands are
|
||||||
# or a fact. They are validated and shell-quoted in the template. The script is root-owned and not writable by the users it runs for.
|
# role inputs (inventory), never read from a user or a fact. They are validated and shell-quoted in the template. The script is
|
||||||
|
# root-owned and not writable by the users it runs for.
|
||||||
# It is world-readable and the commands show in `ps`, so a command must hold no secret. Commands run as the user who logs in.
|
# It is world-readable and the commands show in `ps`, so a command must hold no secret. Commands run as the user who logs in.
|
||||||
- name: Install the tmux auto-start snippet
|
- name: Install the tmux auto-start snippet
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
validate: /bin/sh -n %s
|
validate: /bin/sh -n %s
|
||||||
when: system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages
|
when: system_baseline_tmux_autostart | bool and 'tmux' in __system_baseline_install_packages
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Remove the tmux auto-start snippet
|
- name: Remove the tmux auto-start snippet
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/profile.d/tmux-autostart.sh
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
state: absent
|
state: absent
|
||||||
when: not (system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages)
|
when: not (system_baseline_tmux_autostart | bool and 'tmux' in __system_baseline_install_packages)
|
||||||
become: true
|
become: true
|
||||||
@@ -21,58 +21,6 @@
|
|||||||
mode: "0700"
|
mode: "0700"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
# Opt-in guard (system_baseline_skip_upgrade_during_vzdump, pve only): an upgrade can restart Proxmox services while a backup holds a snapshot
|
|
||||||
# of a guest, so the upgrade waits for the next run when this node has a vzdump task without an end time. Both tasks read state only, so
|
|
||||||
# they run in check mode too; they are skipped where the upgrade is (a dry run of the main flow). `localhost` is the node's own alias, so no
|
|
||||||
# node name and no gathered facts are needed. --source active lists the running tasks: the default, archive, holds only finished ones. The
|
|
||||||
# fact is set on every run, so a guard that is off or skipped never inherits the answer of an earlier run in the same play.
|
|
||||||
- name: List the recent Proxmox tasks of this node
|
|
||||||
ansible.builtin.command:
|
|
||||||
argv:
|
|
||||||
- pvesh
|
|
||||||
- get
|
|
||||||
- /nodes/localhost/tasks
|
|
||||||
- --source
|
|
||||||
- active
|
|
||||||
- --limit
|
|
||||||
- "0"
|
|
||||||
- --output-format
|
|
||||||
- json
|
|
||||||
register: __system_baseline_pve_tasks
|
|
||||||
changed_when: false
|
|
||||||
check_mode: false
|
|
||||||
become: true
|
|
||||||
when:
|
|
||||||
- system_baseline_skip_upgrade_during_vzdump | bool
|
|
||||||
- system_baseline_system_type | default('') == 'pve'
|
|
||||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
|
||||||
|
|
||||||
- name: Check that pvesh answered with a list of tasks
|
|
||||||
ansible.builtin.assert:
|
|
||||||
that:
|
|
||||||
- __system_baseline_pve_tasks.stdout | from_json is sequence
|
|
||||||
- __system_baseline_pve_tasks.stdout | from_json is not string
|
|
||||||
- __system_baseline_pve_tasks.stdout | from_json is not mapping
|
|
||||||
fail_msg: pvesh did not answer with a JSON list of tasks, so the role cannot tell whether a backup is running.
|
|
||||||
quiet: true
|
|
||||||
when: __system_baseline_pve_tasks is not skipped
|
|
||||||
|
|
||||||
- name: Note whether a vzdump backup is running on this node
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
__system_baseline_vzdump_running: >-
|
|
||||||
{{ __system_baseline_pve_tasks is not skipped
|
|
||||||
and (__system_baseline_pve_tasks.stdout | from_json
|
|
||||||
| selectattr('type', 'equalto', 'vzdump')
|
|
||||||
| rejectattr('endtime', 'defined')
|
|
||||||
| list | length) > 0 }}
|
|
||||||
|
|
||||||
- name: Skip the upgrade while a vzdump backup is running
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: >-
|
|
||||||
Skipping the apt upgrade on {{ inventory_hostname }}: a vzdump task is running on this node. Run the update again after the backup
|
|
||||||
has finished.
|
|
||||||
when: __system_baseline_vzdump_running | default(false)
|
|
||||||
|
|
||||||
# safe is the apt module's name for the plain upgrade (apt-get upgrade --with-new-pkgs), what `true` meant here before; dist runs
|
# safe is the apt module's name for the plain upgrade (apt-get upgrade --with-new-pkgs), what `true` meant here before; dist runs
|
||||||
# apt-get dist-upgrade (profile key apt_upgrade, `pve` by default).
|
# apt-get dist-upgrade (profile key apt_upgrade, `pve` by default).
|
||||||
- name: Update & upgrade apt packages
|
- name: Update & upgrade apt packages
|
||||||
@@ -83,9 +31,7 @@
|
|||||||
environment:
|
environment:
|
||||||
TMPDIR: "{{ system_baseline_apt_tmpdir }}"
|
TMPDIR: "{{ system_baseline_apt_tmpdir }}"
|
||||||
become: true
|
become: true
|
||||||
when:
|
when: not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
|
||||||
- not (__system_baseline_vzdump_running | default(false))
|
|
||||||
|
|
||||||
# autoremove must stay in this task: the apt module accepts autoclean alone only together with one of autoremove, name, update_cache or upgrade.
|
# autoremove must stay in this task: the apt module accepts autoclean alone only together with one of autoremove, name, update_cache or upgrade.
|
||||||
- name: Remove unused packages and clean the apt cache
|
- name: Remove unused packages and clean the apt cache
|
||||||
|
|||||||
@@ -75,6 +75,43 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
|
# The extras are appended to the resolved lists. An item must be a Debian package name (policy: lower-case letters, digits, + - . , two or
|
||||||
|
# more characters, starting with a letter or digit), and not end in a minus: apt reads `jq-` as "remove jq", and a null item would become the
|
||||||
|
# package "None". A bare string is rejected here as it is for the blacklist. A package that one input installs and another purges would be
|
||||||
|
# installed and removed on every run, so it stops the run; only overlaps that involve an extra are checked, the resolved lists themselves
|
||||||
|
# are the consumer's.
|
||||||
|
- name: Validate the extra packages
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- system_baseline_extra_packages is sequence
|
||||||
|
- system_baseline_extra_packages is not string
|
||||||
|
- system_baseline_extra_packages is not mapping
|
||||||
|
- system_baseline_extra_packages | select('string') | select('match', '^[a-z0-9][a-z0-9+.-]*[a-z0-9+.]\Z') | list | length
|
||||||
|
== system_baseline_extra_packages | length
|
||||||
|
- system_baseline_extra_remove_packages is sequence
|
||||||
|
- system_baseline_extra_remove_packages is not string
|
||||||
|
- system_baseline_extra_remove_packages is not mapping
|
||||||
|
- system_baseline_extra_remove_packages | select('string') | select('match', '^[a-z0-9][a-z0-9+.-]*[a-z0-9+.]\Z') | list | length
|
||||||
|
== system_baseline_extra_remove_packages | length
|
||||||
|
fail_msg: >-
|
||||||
|
system_baseline_extra_packages and system_baseline_extra_remove_packages must be lists of package names: lower-case letters,
|
||||||
|
digits, + - . only, two or more characters, starting with a letter or digit and not ending in a minus.
|
||||||
|
quiet: true
|
||||||
|
tags: always
|
||||||
|
|
||||||
|
- name: Refuse a package that is both installed and purged
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- system_baseline_extra_packages | intersect(__system_baseline_purge_packages) | length == 0
|
||||||
|
- system_baseline_extra_remove_packages | intersect(__system_baseline_install_packages) | length == 0
|
||||||
|
fail_msg: >-
|
||||||
|
A package is both installed and purged. system_baseline_extra_packages must not name a package of system_baseline_remove_packages or
|
||||||
|
system_baseline_extra_remove_packages, and system_baseline_extra_remove_packages must not name a package of
|
||||||
|
system_baseline_essential_packages. Found: {{ (system_baseline_extra_packages | intersect(__system_baseline_purge_packages)) +
|
||||||
|
(system_baseline_extra_remove_packages | intersect(__system_baseline_install_packages)) }}.
|
||||||
|
quiet: true
|
||||||
|
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.
|
# 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
|
- name: Validate the unattended-upgrades origins
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
|
|||||||
Reference in new issue
Block a user