--- # Caddy is its own playbook (ansible-playbooks/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. - 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 roles/register when this Site'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 the Caddy playbook's # readme, "Trade-off worth knowing". # # Defined after the reload above so that when both are notified the cheap config # reload happens first. - name: Restart Caddy ansible.builtin.systemd_service: name: '{{ caddy_name }}.service' scope: user state: restarted daemon_reload: true listen: Restart Caddy