Cut the comment bloat from the Podman playbooks

Comment blocks now stay within three lines and explain only the non-obvious. Long histories, include examples, and commented-out code are gone. No task, key, or value changed; the only data change is comment text inside the generated unit files.
This commit is contained in:
tanshu committed 2026-10-18 22:10:57 +05:30
1 parent 2aab1aec1e
commit 476a6d7cd0
85 files changed
+372 -2433

No files matched your search

@@ -1,9 +1,4 @@
---
# Audiobookshelf as a rootless Podman Quadlet unit.
#
# Everything here runs as {{ podman_user }} — the connection user. No become, no
# XDG_RUNTIME_DIR: the SSH connection gave us a real PAM session, so systemd's
# user manager is reachable through the standard environment.
- name: Ensure the Audiobookshelf data directories exist
ansible.builtin.file:
@@ -13,9 +8,7 @@
group: "{{ podman_user }}"
mode: '0755'
loop:
# config/ and metadata/ are the irreplaceable 22 MB — absdatabase.sqlite,
# migrations, backups, cache, logs. audiobooks/ and podcasts/ are the
# library, which the app reads and podcast downloads are written into.
# config/ and metadata/ hold irreplaceable state; the media directories can be re-downloaded.
- "{{ config_dir }}"
- "{{ metadata_dir }}"
- "{{ audiobooks_dir }}"
@@ -41,9 +34,7 @@
state: started
daemon_reload: true
rescue:
# systemd reports "control process exited with error code" and nothing
# else, which is useless for the usual failures (an unattached network, an
# unwritable /config, a bad volume). Pull the real reason out.
# systemd reports only a generic exit error, so collect the real reason.
- name: Collect Audiobookshelf diagnostics
ansible.builtin.command: "{{ item }}"
loop:
@@ -62,18 +53,15 @@
ansible.builtin.fail:
msg: "Audiobookshelf did not start — see the diagnostics above."
# Quadlet honours [Install] WantedBy= when it generates the unit, so
# `systemctl --user enable` is neither needed nor possible on a generated unit.
# Quadlet honours WantedBy=, so systemctl enable is neither needed nor possible on a generated unit.
- name: Verify Audiobookshelf is running
ansible.builtin.command: "systemctl --user is-active {{ unit_name }}"
register: audiobookshelf_active
changed_when: false
failed_when: audiobookshelf_active.stdout != 'active'
# `is-active` says the container is running; it does not say the app can serve.
# `Restart=always` means even a crash-looping container is reported active. The
# image ships no HEALTHCHECK, so the unit defines one (HealthCmd=, see the
# template) and this runs exactly that command once, synchronously.
# is-active still reports active for a crash-looping container, and the image ships no HEALTHCHECK.
# The unit defines one instead, and this runs exactly that command once.
- name: Wait for Audiobookshelf to pass its health check
ansible.builtin.command: "podman healthcheck run {{ container_name }}"
register: audiobookshelf_health
@@ -88,10 +76,7 @@
changed_when: false
failed_when: audiobookshelf_mounts.rc != 0
# The health check proves the server started — it exits 1 with EROFS if /config
# is not writable — but not that /config is the *bind mount*. This does: the
# database the app has just created has to appear on the host, not inside the
# container's writable layer.
# The health check proves the server started, not that /config is the bind mount.
- name: Check the database landed on the host
ansible.builtin.stat:
path: "{{ config_dir }}/absdatabase.sqlite"
@@ -106,10 +91,7 @@
container, visible on the host, so the bind mount is real.
when: audiobookshelf_db.stat.exists
# This is the check that catches a broken or missing Volume= line, which is the
# one failure here that is silent: the app would run perfectly well with its
# data in the container's writable layer, and lose all of it on the next
# recreate.
# A missing Volume= would let the app write to the container layer and lose the data on recreate.
- name: Fail if the database is not on the host
ansible.builtin.assert:
that: audiobookshelf_db.stat.exists
+4 -16
View File
@@ -1,27 +1,15 @@
---
# Caddy is its own playbook (caddy/playbook.yml) and a rootless Quadlet unit
# there. These handlers run as the connection user, so `systemctl --user` and
# `podman exec` work without any XDG_RUNTIME_DIR juggling.
# Notified by this role when the Caddyfile changes. A reload keeps existing
# connections; a restart would briefly drop every hosted site.
#
# Note the config path: /etc/caddy/Caddyfile is the mount inside the container,
# not {{ caddyfile_path }}, which is the host side of it.
# A reload keeps live connections; a restart would drop every hosted site.
# The path is inside the container, not the host {{ caddyfile_path }}.
- name: Reload Caddy configuration
ansible.builtin.command: >-
podman exec {{ caddy_name }} caddy reload --config /etc/caddy/Caddyfile
changed_when: true
listen: "Reload Caddy"
# Notified by caddy/roles/register when this service's network unit, or the
# drop-in that attaches Caddy to it, is written. Quadlet has no live equivalent
# of `docker network connect`, so the container has to be recreated — a brief
# restart of every hosted site, not just this one. See caddy/readme.md,
# "Trade-off worth knowing".
#
# Defined after the reload above so that when both are notified the cheap
# config reload happens first.
# Quadlet cannot attach a network live, so Caddy must be recreated.
# Defined after the reload so the cheap reload runs first when both are notified.
- name: Restart Caddy
ansible.builtin.systemd_service:
name: "{{ caddy_name }}.service"
@@ -1,14 +1,4 @@
---
# Append this site's block to the shared Caddyfile.
#
# The Caddyfile is a bind mount into the Caddy container, so Caddy sees the
# change as soon as the file is written; the handler only asks Caddy to re-read
# it. That is a reload, not a restart, so the other hosted sites are untouched.
#
# blockinfile is idempotent on its own via the marker, so there is no need to
# slurp the file and compare first — which also matters because slurp *fails*
# when the Caddyfile does not exist yet, on a host where the Caddy playbook has
# not run.
- name: "Add the {{ host }} site block to the Caddyfile"
ansible.builtin.blockinfile: