Files
playbooks/sms-wa-bridge/roles/sms-wa-bridge/handlers/main.yaml
T
2026-10-18 21:35:53 +05:30

30 lines
1.3 KiB
YAML

---
# All handlers run as the connection user ({{ podman_user }}), so systemctl
# --user works without setting XDG_RUNTIME_DIR.
#
# The `systemd_service` handlers — this one and Caddy's, in roles/caddy — carry
# `when: not ansible_check_mode`: under --check the unit file was never written,
# so systemd cannot find the unit and a restart would fail rather than be
# skipped. The `command` handler below needs no guard: Ansible skips those under
# --check on its own.
- name: Reload systemd user units
ansible.builtin.command: systemctl --user daemon-reload
changed_when: true
listen: Reload systemd user units
# A changed unit file, a changed environment file, or a rebuilt image — all of
# them mean the app is recreated. Everything it owns is on the four bind mounts,
# so a recreate loses nothing: the linked-device session, the routing rules and
# the log all live on the host. It is a few seconds during which incoming SMS
# get a connection error from Caddy rather than a 200, which MacroDroid will
# retry or drop depending on how the action is configured.
- name: Restart sms-wa-bridge
ansible.builtin.systemd_service:
name: "{{ unit_name }}"
scope: user
state: restarted
daemon_reload: true
when: not ansible_check_mode
listen: Restart sms-wa-bridge