From c9506e2db0474a7fb2a9078fb85a975d4b9160b2 Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 9 Nov 2026 20:35:50 -0700 Subject: [PATCH] Deploys always pull images; dockcheck recreates only what it updated Compose deploys used the default pull policy (missing), so switching a service to a tag that was already cached deployed a year-old image (paperless-ngx and heyform :latest). module_defaults now sets pull: always for every docker_compose_v2 task. dockcheck pulls the image it updates, but then ran compose up for the whole stack, which could recreate other containers in the stack from cached images, including ones it excludes. OnlySpecific=true limits it to the updated container. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 1 + roles/cron/templates/dockcheck.config.j2 | 5 +++++ site.yml | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 16b216e..ffaa1f0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -112,6 +112,7 @@ Never hardcode domains, IPs or secrets in templates; use these variables. - Public access: subdomain in `domains.yml`, route in `Caddyfile.j2`, A record in `dns.yml`. - Use `diff: false` / `no_log: true` on tasks that write secrets. - Add the label `mag37.dockcheck.update: true` if dockcheck may update it unattended. +- Deploys pull every image fresh (`pull: always` in `site.yml` module_defaults), so a `latest` tag deploys the current release. A deploy therefore also upgrades anything on a floating tag; pin `_version` to hold it. ### DNS `dns.yml` manages Route53 A records for both domains with a Route53-only IAM diff --git a/roles/cron/templates/dockcheck.config.j2 b/roles/cron/templates/dockcheck.config.j2 index fe5652c..379356c 100644 --- a/roles/cron/templates/dockcheck.config.j2 +++ b/roles/cron/templates/dockcheck.config.j2 @@ -37,6 +37,11 @@ MonoMode=true # Add release-note links (from urls.list) to each update listed PrintReleaseURL=true +# Recreate only the container that was updated, not its whole compose stack. +# Otherwise the stack's other containers (excluded or unlabelled ones too) +# get recreated from whatever image is cached locally. +OnlySpecific=true + # Exclude containers from checking Exclude="dawarich_redis,dawarich_db" diff --git a/site.yml b/site.yml index 4f7e7de..48e76ba 100644 --- a/site.yml +++ b/site.yml @@ -2,6 +2,12 @@ - hosts: docker become: true + # Always fetch each image tag from the registry before compose up. The + # default only pulls missing images, so a tag that was already cached (say + # :latest from a year ago) got deployed as-is. + module_defaults: + community.docker.docker_compose_v2: + pull: always roles: - { role: common, tags: ["common"] } - { role: docker, tags: ["docker"] }