Files
computer-playbook/roles/web-app-discourse/handlers/main.yml
kevinveenbirkenbachandClaude Opus 5 f47ea0e5bb fix(discourse): bootstrap only for what the bootstrap consumes
Three notifiers pointed at one handler, and that handler always ran
./launcher rebuild. A rotated database password therefore cost a full image
build with bundle install and asset precompile: 961.82s in pass 1 and 13m16s
in pass 2 of job 103878400427, on a run that then missed its wall-clock
budget by 201s.

The launcher draws the line itself. set_template_info reads app.yml on every
call and turns env: into -e flags that run_start hands to docker run, while
templates:, params: and hooks: are consumed during bootstrap only. An env:
change needs a new container, not a new image. run_start takes the docker run
branch only when no container exists, which is why the start path still stops
and removes it first.

The digest task is the discriminator: it records a sha256 over every top-level
key except env:, so a credential-only change leaves it untouched and the
bootstrap handler is never notified. A hash rather than the content because
that section carries the OIDC client secret and the administrator password.

The guard against running both paths lives in a fact cleared per role run. A
register from inside the included file would have outlived the play and, in a
later one, silently skipped the recreate while the config change never reached
the container.

from_yaml adds no failure mode: the launcher parses the same file with
YAML.load, so anything it rejects was already a broken deployment. start
without an image is structurally impossible, since a running container
implies its image and a missing one notifies the bootstrap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 15:28:38 +02:00

22 lines
557 B
YAML

---
- name: "🔨 Bootstrap the stack host image"
include_tasks: stack_host.yml
vars:
DISCOURSE_LAUNCHER_ACTION: rebuild
when: IS_STACK_HOST | bool
listen: rebuild-discourse
- name: "📝 Record that the bootstrap already recreated the container"
ansible.builtin.set_fact:
DISCOURSE_REBUILT: true
listen: rebuild-discourse
- name: "🖥️ Handle stack host"
include_tasks: stack_host.yml
vars:
DISCOURSE_LAUNCHER_ACTION: start
when:
- IS_STACK_HOST | bool
- not DISCOURSE_REBUILT | bool
listen: recreate-discourse