fix(ansible): make apt itself wait for the dpkg lock #68

Merged
jfraeys merged 1 commit from jfraeys/fix/apt-dpkg-lock-timeout into main 2026-10-11 15:48:01 -04:00
Owner

Staging run 471: backups : Install restic failed 4s after starting with Could not get lock /var/lib/dpkg/lock-frontend ... (unattended-upgr) despite the play's lock_timeout: 300. That module option only covers python-apt's cache lock; the apt-get it spawns fails immediately. A pre-task now drops /etc/apt/apt.conf.d/99dpkg-lock-timeout (DPkg::Lock::Timeout "600") so every apt-get in the play waits, in services, web, hardening and ci-ephemeral.

Verified in a Debian 12 container with a real fcntl lock holder: without the file apt-get fails at once (rc 100, same message); with it, it waited 8s for the lock and succeeded. ansible-lint, yamllint and syntax-check pass for all four playbooks. The file persists on hosts (harmless in steady state). The ci-ephemeral change reaches the provisioner after a role redeploy. 🤖 Generated with Claude Code

Staging run 471: `backups : Install restic` failed 4s after starting with `Could not get lock /var/lib/dpkg/lock-frontend ... (unattended-upgr)` despite the play's `lock_timeout: 300`. That module option only covers python-apt's cache lock; the apt-get it spawns fails immediately. A pre-task now drops `/etc/apt/apt.conf.d/99dpkg-lock-timeout` (`DPkg::Lock::Timeout "600"`) so every apt-get in the play waits, in services, web, hardening and ci-ephemeral. Verified in a Debian 12 container with a real fcntl lock holder: without the file apt-get fails at once (rc 100, same message); with it, it waited 8s for the lock and succeeded. ansible-lint, yamllint and syntax-check pass for all four playbooks. The file persists on hosts (harmless in steady state). The ci-ephemeral change reaches the provisioner after a role redeploy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(ansible): make apt itself wait for the dpkg lock
All checks were successful
Lint / lint (pull_request) Successful in 1m17s
Secret scan / scan (pull_request) Successful in 15s
1f5a496835
module_defaults lock_timeout only covers python-apt's cache lock; the apt-get it spawns failed at once on
unattended-upgrades' lock (staging run 471, backups: Install restic). A pre-task drops an apt.conf.d file with
DPkg::Lock::Timeout 600 in services, web, hardening and ci-ephemeral.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfraeys/infra!68
No description provided.