Add gluetun endpoint watcher (5-minute systemd timer)
When gluetun is unhealthy, re-dig the WireGuard peer hostname, update wg0.conf Endpoint, recreate gluetun then qbittorrent, and verify the VPN exit IP. Keeps torrent path alive when provider endpoints rotate.
This commit is contained in:
parent
b55754ee49
commit
218e64314d
8 changed files with 249 additions and 1 deletions
|
|
@ -277,6 +277,38 @@
|
|||
failed_when: false
|
||||
tags: [stack]
|
||||
|
||||
- name: Ensure gluetun-endpoint-watch.sh is executable
|
||||
ansible.builtin.file:
|
||||
path: "{{ stack_root }}/scripts/gluetun-endpoint-watch.sh"
|
||||
mode: "0755"
|
||||
owner: "{{ stack_owner }}"
|
||||
group: "{{ stack_group }}"
|
||||
tags: [stack, gluetun-watch]
|
||||
|
||||
- name: Install gluetun endpoint watch systemd unit
|
||||
ansible.builtin.template:
|
||||
src: gluetun-endpoint-watch.service.j2
|
||||
dest: /etc/systemd/system/gluetun-endpoint-watch.service
|
||||
mode: "0644"
|
||||
notify: Reload systemd
|
||||
tags: [stack, gluetun-watch]
|
||||
|
||||
- name: Install gluetun endpoint watch timer (every 5 minutes)
|
||||
ansible.builtin.template:
|
||||
src: gluetun-endpoint-watch.timer.j2
|
||||
dest: /etc/systemd/system/gluetun-endpoint-watch.timer
|
||||
mode: "0644"
|
||||
notify: Reload systemd
|
||||
tags: [stack, gluetun-watch]
|
||||
|
||||
- name: Enable and start gluetun endpoint watch timer
|
||||
ansible.builtin.systemd:
|
||||
name: gluetun-endpoint-watch.timer
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
tags: [stack, gluetun-watch]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Persist stack across reboots
|
||||
# - Every service in docker-compose.yml uses restart: unless-stopped
|
||||
|
|
|
|||
|
|
@ -39,3 +39,7 @@ FORGEJO_SSH_PORT={{ forgejo_ssh_port }}
|
|||
FORGEJO_DOMAIN={{ forgejo_domain }}
|
||||
FORGEJO_ROOT_URL={{ forgejo_root_url }}
|
||||
FORGEJO_DISABLE_REGISTRATION=false
|
||||
|
||||
# WireGuard peer hostname for gluetun-endpoint-watch (re-dig when tunnel dies)
|
||||
WIREGUARD_ENDPOINT_HOST={{ wireguard_endpoint_host | default('las-183-wg.whiskergalaxy.com') }}
|
||||
WIREGUARD_ENDPOINT_PORT={{ wireguard_endpoint_port | default('443') }}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=Watch gluetun health and refresh WireGuard endpoint if needed
|
||||
After=docker.service network-online.target
|
||||
Requires=docker.service
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User={{ stack_owner }}
|
||||
Group={{ stack_group }}
|
||||
WorkingDirectory={{ stack_root }}
|
||||
Environment=STACK_DIR={{ stack_root }}
|
||||
Environment=HOME=/home/{{ stack_owner }}
|
||||
# Host is set in .env (WIREGUARD_ENDPOINT_HOST); script also reads .env
|
||||
ExecStart={{ stack_root }}/scripts/gluetun-endpoint-watch.sh
|
||||
Nice=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Run gluetun endpoint watch every 5 minutes
|
||||
|
||||
[Timer]
|
||||
OnBootSec=2min
|
||||
OnUnitActiveSec=5min
|
||||
AccuracySec=30s
|
||||
Persistent=true
|
||||
Unit=gluetun-endpoint-watch.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue