Keeping a deployment up to date¶
A deployment changes in three ways. Debian updates its own packages once a day. The roles pull or rebuild their container images when they run, which is only when somebody runs them. And the versions written down in the repository move only with a commit. This chapter says which part of the stack changes in which way, how to see that something is waiting, when to go ahead and when to ask first, and how a change is rolled out. Moving to a new Debian release is a procedure of its own, see Upgrading.
What updates itself¶
Debian packages¶
The unattended-upgrades role switches on apt’s periodic runs:
apt-daily.timer fetches the package lists and apt-daily-upgrade.timer
runs unattended-upgrades, once a day each. Which packages get installed is
decided by the 50unattended-upgrades file that ships with the Debian
package, and the role leaves it as it is: the security archive of the running
release, and the release itself, which changes at every point release.
<codename>-updates is not on that list; what arrives there waits for a
person and is only counted.
unattended-upgrades never reboots the host
(ae_unattended_upgrades_automatic_reboot is false). A new kernel is
installed, but it only runs after a reboot, and that is left to a person; see
Reboots.
On a Debian 12 host the podman role holds every package from the Kubic
repository, so apt never upgrades podman, conmon, crun and the rest there;
Upgrading explains why.
Nextcloud apps¶
The Nextcloud container runs the role’s configure.sh every time it starts
(the image’s before-starting hook). The script switches the app store on,
runs occ app:update --all and switches the store off again, so every
restart of ae-nextcloud brings the apps to their newest release for the
running Nextcloud version. Nextcloud itself is not updated this way: the
update notification app is disabled, the web updater is switched off
(upgrade.disable-web), and the server version moves only with the image
tag, see below.
What a playbook run brings¶
Container images are pulled or built by the role that runs the container, at the moment the role runs, and at no other time. No timer on the host pulls an image, and podman’s auto-update is not used. What a run brings depends on how the role names its image.
Kind |
Roles |
What it takes |
|---|---|---|
Pinned to a version |
|
A new release: a commit that changes the version, then a run of the
role. A rebuild of the same tag: a run for |
Floating tag |
|
A run of the role. |
Built on the host |
|
A run of the role. |
- Pinned to a version
The version is a variable in the role’s
defaults/main.yml; for Nextcloud it isae_nextcloud_versioninansible/group_vars/all.yml, so that a host can override it. A new release needs a commit that changes the value, and then a run of the role. Docker’s official images re-push a released tag when the base under it gets fixes.caddyandnextcloudpull their tag again on every run (forceon the pull) and restart their container only when the digest moved, so for them a run is enough to get a rebuilt tag. The other pinned roles never fetch a tag again once the host has it; a rebuilt tag takespodman pulland a restart of the unit by hand, see Container image outdated.- Floating tag
roundcubefollows its release branch,postgresandredistheir major version. Each run pulls the tag again and restarts the container when the digest moved, so point releases arrive with any run of the role.postgresis the exception: it pulls but does not restart, because every application that requires it would restart along with it. The new image is used from the next deliberate restart ofae-postgresor the next reboot.mattermost’srelease-11floats as well, but it is never pulled again once the image is on the host.- Built on the host
postfix,dovecot,rspamdandunboundbuild on a freshdebian:trixiewithout a layer cache.mailmanbuilds from thedocker-mailmansubmodule, its web image onalpine:3.23.seam,knutt,websiteandbokstaevercheck out the branch they follow and build from it;websitewithae_website_sourceset builds from a checkout on the control machine instead. Every run of these roles pulls the base image again (--pull=always) and rebuilds, so the packages inside are as current as the last run, and no newer: nothing rebuilds them in between. A run of a role that follows a branch also deploys whatever that branch holds at the moment. A new mailman release is a commit that moves the submodule.
Reboots¶
A kernel update, and any other package that needs a reboot, creates
/run/reboot-required and adds its name to /run/reboot-required.pkgs.
Both files are on a tmpfs, so the reboot removes them. A reboot takes every
service on the host away for a few minutes, which is why nothing does it
unattended; the “Reboot pending” alert says when one has waited for three
days. Kernel updates come about once a month.
Pick a time when few people use the services, and reboot:
cat /run/reboot-required.pkgs
systemctl reboot
When the host is back, systemd has started the containers in their usual order:
uname -r
systemctl list-units 'ae-*' --state=failed
podman ps
uname -r names the new kernel, no unit is failed, and podman ps lists
the containers again. The reboot also starts PostgreSQL on the image the
postgres role pulled last. “Reboot pending” resolves a few minutes after
the boot, once the update metrics have run.
Seeing what is waiting¶
Two timers write what is pending into node-exporter’s textfile collector
(/ae/node-exporter/textfile/), and Grafana alerts on it. The mails go to
the addresses in ae_grafana_alert_addresses (see
Becoming an admin); the alert rules page in Grafana shows the current
state of every rule.
ae-update-metrics, from theunattended-upgradesroleRuns hourly, two minutes after a boot, and right after every
apt-dailyandapt-daily-upgraderun, and writesae-updates.prom: whether a reboot is pending and since when, the pending upgrades with the security ones counted apart, the age of apt’s copy of the Debian security index, and how many unattended-upgrades runs in a row have failed. It never takes apt’s lock and never runsapt-get update.ae-image-update-check, from thepodmanroleRuns hourly and compares the image of every running container that came from a registry - including containers that no role manages - with what its tag points at in the registry now, and writes
ae-image-updates.prom. It asks with anonymous HEAD requests, asks about each tag once per UTC day and again after a container of that tag was restarted, and never pulls. Images built on the host are not checked.
The alert rules on these metrics:
Alert |
Fires when |
|---|---|
Reboot pending |
a reboot was first asked for more than 3 days ago |
Security updates pending |
security updates have been pending for more than 2 days without a break |
Unattended upgrades failing |
the last two runs of unattended-upgrades, or more, logged an error |
Package lists stale |
apt’s copy of the Debian security index is more than 3 days old, for 2 hours |
Container image outdated |
the tag of a running container has pointed at another image for more than 7 days |
Container image check failing |
the registry has not answered for a tag for more than 3 days |
A deployment that lists unattended-upgrades or podman in
ae_disabled_roles gets none of that role’s rules.
On the host the same information is one command away:
cat /ae/node-exporter/textfile/ae-updates.prom
cat /ae/node-exporter/textfile/ae-image-updates.prom
apt list --upgradable
What no alert covers:
A new release of a pinned image. The image check compares a container with its own tag, and
34.0.4-fpmdoes not move when34.0.5-fpmappears. Somebody has to follow the releases and security announcements of the software in the stack.The packages inside the images built on the host. They are as current as the last run of their role.
Updates from
<codename>-updates. They are counted (ae_apt_upgrades_pending{origin="other"}), but no rule looks at them.
Going ahead or asking first¶
These rules are there so that a routine update does not wait for the one person who usually does it, and a risky one does not happen by accident.
- Go ahead
A rebuilt image under a tag that already runs, a point release of a floating tag, a rebuild of the images built on the host, and a patch release of a pinned image (Caddy
2.11.7to2.11.9, Nextcloud34.0.4to34.0.5). Security fixes usually are of this kind. Follow the procedure below and tell the other admins afterwards.- Read the release notes first
A minor release of a pinned image (Grafana
13.2to13.3, Prometheusv3.15tov3.16). Go ahead when the notes name no breaking change, no change to the configuration and no migration to run by hand; otherwise treat it as a major release. A project that is still at0.x, like lldap, can break things in a minor release, so treat those as major releases too.- Ask first
A major release (Nextcloud
34to35, a new Roundcube branch, a new PostgreSQL or Redis major), anything that migrates a database, and a new Debian or Alpine release, for the host or for the images built on it. Agree on it with the other admins, take a backup and a snapshot, and pick a time when somebody can watch it through. Many of these cannot be undone except from the backup.
The comment above a version variable says what moving it involves; read it before changing the value. At the time of writing:
ae_nextcloud_versioninansible/group_vars/all.ymlhas to match or be newer than the installed version. The image refuses to downgrade and to skip a major, so a host several majors behind moves one major at a time. Keep it on the latest patch release, for the reason in the example below.ae_roundcube_version: a new branch is a one-way upgrade. On start the image copies the new release over the web volume and migrates the database schema in place; going back means restoring both.ae_postgres_version: a new major does not migrate the data, the server refuses to start on it.upgrade-postgres.ymldoes the migration; its header describes the run.ae_lldap_version: the database schema is migrated on start, so only ever move it forward.ae_prometheus_version: Prometheus 3 reads the data of 2.x, but cannot go back below 2.55 once it has written to it.ae_redis_version: newer servers read the dump files of older ones, not the other way round.
Rolling out a change¶
Every deployment runs from a clone of its own. Commit a version bump in the
clone you work in, one variable per commit (the subject is the role and the
new version, caddy: 2.11.9), and push it. Then, in the deployment’s
clone:
Bring the clone up to date.
git status --short git pull --ff-only git submodule update --init --recursive cd ansible make collections
git statusmust show nothing: the files of the deployment are all ignored by git, and a deployment clone has no changes of its own.make collectionsis only needed whenrequirements.ymlchanged.Run the role in check mode, with a diff.
ansible-playbook -i hosts.ini setup.yml --check --diff --tags nextcloud </dev/null
</dev/nullkeeps Ansible from treating the terminal as stdin. Read the diff. For a version bump it is theImage=line of the container unit and nothing else. Two kinds of task report a change in check mode whatever the state on the host: every pull withforceand every image build, because the module cannot ask the registry without pulling. The handlers they notify are listed as if they would run. If a version in the diff goes down, stop: the clone is behind what runs on the host, and the run would roll it back. Not every template that contains a secret is kept out of the diff, so do not paste the output anywhere.Run it for real.
ansible-playbook -i hosts.ini setup.yml --tags nextcloud </dev/null
Check the result on the host.
systemctl list-units 'ae-*' --state=failed podman ps --format '{{.Names}} {{.Image}} {{.Status}}' systemctl start ae-image-update-check.service grep 'update_available{' /ae/node-exporter/textfile/ae-image-updates.prom
No unit is failed, the container runs the new image and has just started, and the image check reports
0for it (1means it is still behind its tag). Then use the service once in a browser or a mail client.Tell the other admins what you changed.
Example: PHP2Shell, October 2026¶
On 2026-10-21 PHP released fixes for CVE-2026-109618 and CVE-2026-109619, two remote code executions that need no login and were confirmed on PHP-FPM; for the 8.5 branch the fix is PHP 8.5.12. PHP runs in the Nextcloud image, in the Roundcube image and, on hosts that have one, in a WordPress container that is run by hand outside the repository. Each of the three got the fix in a different way.
- Roundcube: floating tag
1.7.x-fpmwas rebuilt upstream on the fixed PHP. The role pulls its tag on every run, so running it was enough:ansible-playbook -i hosts.ini setup.yml --tags roundcube </dev/null
- Nextcloud: a pinned tag that was not rebuilt
The hosts ran
34.0.4-fpm. Upstream rebuilt34.0.5-fpmon the fixed PHP but not34.0.4-fpm, because a patch tag that has been superseded is never rebuilt.34.0.4-fpmstayed on PHP 8.5.11, and a run of the role would have pulled the same vulnerable image again. The fix was a patch release, so a case for going ahead: a commit that setae_nextcloud_versionto34.0.5-fpm(cd0e284, “nextcloud: 34.0.5 for PHP 8.5.12”), then a run with--tags nextcloud.- The container run by hand
No role runs it, so no playbook run fetches anything for it. As root on the host:
podman pullof its tag, then a restart of its unit.
After each, podman exec ae-nextcloud php -v (and the same for
ae-roundcube) prints the PHP version that now runs.
The alerts did not exist at the time. With them, “Container image outdated” fires for Roundcube and for the container run by hand once their tags have been ahead for seven days, and not at all for Nextcloud, whose tag never moved. For a hole that anybody on the internet can use, a week is far too long. The alerts catch what nobody noticed; they are not the way to learn about a critical hole. That takes somebody reading the announcement, looking up which images run the affected software, and acting on it.
When an alert fires¶
The mail names the host and, for the image rules, the container and the image.
Reboot pending¶
An installed update has waited more than three days for a reboot.
/run/reboot-required.pkgs names it. Reboot as described under
Reboots.
Security updates pending¶
Security updates have been pending for more than two days, so unattended-upgrades is not installing them. The usual reasons are an upgrade that needs a new package or the removal of one, and a configuration file that was changed on the host, which would need a question answered.
apt list --upgradable
unattended-upgrade --dry-run --debug
less /var/log/unattended-upgrades/unattended-upgrades.log
The debug output of the dry run shows what it skips and why. Read what
apt upgrade (apt full-upgrade when a package has to go) wants to do
and install the updates by hand, then refresh the metrics with
systemctl start ae-update-metrics.service.
Unattended upgrades failing¶
The last two runs or more logged errors. apt-daily-upgrade.service
reports success either way, so this alert is the only place where a failed
run shows. The end of /var/log/unattended-upgrades/unattended-upgrades.log
says what went wrong: often the apt lock held by somebody else, which is gone
by the next run, or an interrupted dpkg run (dpkg --audit lists what it
left behind, dpkg --configure -a finishes it). Once the cause is fixed,
run unattended-upgrade --debug by hand. A run without errors resets the
count, and systemctl start ae-update-metrics.service publishes it.
Package lists stale¶
apt’s copy of the Debian security index is more than three days old.
apt-get update has not got through, so the pending security updates are
invisible and unattended-upgrades installs none.
journalctl -u apt-daily.service shows the error, and apt-get update
run by hand shows it again: an expired key, a mirror that moved, no way out
of the host. Fix it, then run systemctl start ae-update-metrics.service.
If the alert has no value at all, the metrics file is missing: check
systemctl status ae-update-metrics.timer, and run the
unattended-upgrades role.
Container image outdated¶
The tag a running container was started from has pointed at another image in the registry for more than seven days, usually an official image that was rebuilt on a fixed base. What to do depends on who runs the container:
caddy,nextcloud,roundcube,redisand the page cache ofbokstaeverpull withforce: run the role, as in Rolling out a change.ae-postgres: run thepostgresrole, which pulls but does not restart, then restartae-postgres.serviceat a quiet time - the applications that require it restart with it - or leave it to the next reboot.Every other container, from a pinned role without
force, frommattermostor from a unit that no role manages: pull the image exactly as the alert names it, and restart the unit that runs the container. For the roles that is the container name with.service.podman pull docker.io/grafana/grafana:13.2.5 systemctl restart ae-grafana.service
Then systemctl start ae-image-update-check.service; the alert resolves
within about ten minutes. If it does not, the role pulled nothing new because
the image was on the host already - pulled by hand, or by another role with
the same image (redis and the page cache of bokstaever share one) -
and so it did not restart the container: restart its unit.
Container image check failing¶
The registry has not answered for a tag for more than three days, so that
container is no longer watched. journalctl -u ae-image-update-check.service
names the tag and the error: an HTTP status, a registry that wants a login,
a repository that is gone, no way out of the host. A failed request is tried
again on the next hourly run. The check has no credentials, on purpose; an
image from a registry that requires a login cannot be watched this way, and
the alert for it is best silenced in Grafana, with a note saying why.