package_hold
Holds a package back from updates, or releases it: apt-mark hold on Debian and Ubuntu, dnf versionlock on the Red Hat family. It doesn’t install the package.
Use package_hold to keep a package at the version it has while the rest of the host updates, such as the kernel on a host with a driver built for it, or a database you upgrade by hand. It’s apt-mark hold on Debian and Ubuntu and dnf versionlock on the Red Hat family. It doesn’t install anything: put a package step first if the package isn’t there yet.
Example usage
Section titled “Example usage”Hold PostgreSQL where it is. Steps run in the order written, so the hold comes after the install:
step "postgres" { package { name = "postgresql16-server" }}
step "postgres_held" {
package_hold { name = "postgresql16-server" }}On Rocky Linux, AlmaLinux and RHEL, dnf versionlock is a plugin. Install it first:
step "versionlock" { package { name = "python3-dnf-plugin-versionlock" }}Let it update again, when you’re ready:
step "postgres_held" { package_hold { name = "postgresql16-server" state = "released" }}Arguments
Section titled “Arguments”| Name | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Package name, such as kernel or postgresql16-server. |
on_remove |
string | No | What happens on the host when this resource is removed: “forget” (default) leaves the hold as it is, “delete” releases it. |
state |
string | No | “held” (default) keeps the package at its version through updates; “released” lets it update again. |
Read-only attributes
Section titled “Read-only attributes”Conn3x sets these; reference them as conn3x_package_hold.<circuit>__<step>["<host>"].<name>.
| Name | Type | Description |
|---|---|---|
in_sync |
bool | Whether the package was held, or released, as it should be at the last refresh. |
revision |
string | Changes each time Conn3x changes this on the host. Handlers watch it. |
A step lowers to the conn3x_package_hold resource, one instance per host, and connects with its circuit’s ssh block.
How it works
Section titled “How it works”Holding. On the Debian family, Conn3x runs apt-mark hold, and apt-mark unhold to release. On the Red Hat family it runs dnf versionlock add, which locks the installed version, and dnf versionlock delete to release. A hold needs the package installed: holding one that isn’t fails and says to install it first, since there’s no version to hold, and releasing one that isn’t is fine. After the command, Conn3x reads the list back, because dnf versionlock exits 0 even for a name it can’t find, as with a typo. Fedora’s dnf 5 has versionlock built in. dnf 4, on Rocky Linux 10, AlmaLinux and RHEL, needs python3-dnf-plugin-versionlock, and without it the step fails and names that package.
Reading. Every plan reads apt-mark showhold or dnf versionlock list. A hold someone released by hand, or one someone added, shows the step out of sync, and the next apply puts it back the way the step says. Apply changes nothing when the host already matches.
What a hold does. apt upgrade and dnf upgrade leave a held package at its version, so a routine update, by hand, by unattended-upgrades or by dnf-automatic, can’t move it. To move it on purpose, release it, upgrade, and hold it again.
Removal
Section titled “Removal”Deleting a package_hold step leaves the hold as it is. With on_remove = "delete", it releases it.