Three files existed only as second copies of things group_vars/all already
auto-loads, and 34 playbooks named them in vars_files: - which outranks
group_vars, so the copies won. The day someone edited one and not the other,
those plays would silently keep the stale value. infra_vars.yml was already
drifting: group_vars/all/main.yml had grown age_backup_recipient and
backup_pull_public_key that it lacked.
infra_vars.yml - a strict subset of group_vars/all/main.yml
infra_secrets.yml - decrypts byte-identical to group_vars/all/vault.yml
infra_secrets.yml.example - documented Uptime Kuma credentials as the reason
the file exists, which stopped being true
Deleted, along with 62 vars_files entries across 34 playbooks (12 of which
named ../../group_vars/all/main.yml directly - same defect, a vars_files entry
duplicating an auto-loaded file at higher precedence than the file itself).
Checked before touching anything: infra_secrets.yml was listed LAST in 10 plays,
after services_config.yml, so removal would flip precedence if the two shared a
key. They share none, and neither does services_config.yml with
group_vars/all/main.yml, so the removal is provably inert.
services_config.yml was the last one standing. It held four unrelated things:
caddy_sites_dir - an identical copy of roles/caddy_site/defaults/.
Deleted; the role default is now the only one.
*.tailscale_hostname (x3) - a THIRD copy of each box's identity, which
inventory.ini already holds as ansible_host.
Deleted. Edge plays now read
hostvars['<host>'].ansible_host - verified an
edge play resolves that with nothing loaded and
the other host in no play. Three copies of one
name is how bitcoin_rpc_host ended up labelled
"knots_box" while pointing at fulcrum-box.
subdomains, ntfy topic, - genuinely global: their readers span managed,
headscale namespace monitoring, vpn_control and edge, so no single
group covers them. Moved to group_vars/all/main.yml
where they auto-load. The ntfy_topic and
headscale_namespace indirection through
service_settings collapses to the global name.
the four cross-host ports - the only entries with a real justification.
Left in place; they move in the next commit.
Also dead, all Uptime Kuma residue or duplication:
phoenixd_monitor_name, forgejo_runner healthcheck_timeout_seconds/retries,
fulcrum_tailscale_hostname, and bitcoin_knots_version - the last being a
v-prefixed copy of bitcoin_knots_version_short that nothing read, two
hand-maintained copies of one version string.
Corrected a false comment: services_config.yml claimed the uptime_kuma subdomain
"no longer resolves to anything". It resolves to 164.92.239.72 and answers HTTP
302, and 11 playbooks still template it. Same wrong premise as PLAN_3.
Verification: all 37 playbooks' --list-tasks output is byte-identical before and
after. A probe resolving all 22 values services_config.yml used to supply returns
21 identical and one intended deletion (caddy_sites_dir, now role-only - confirmed
the role still resolves it: "Ensure Caddy sites-enabled directory exists" comes
back ok against the real path). memos check-diff identical before and after.
Syntax passes on every playbook.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
212 lines
7.7 KiB
YAML
212 lines
7.7 KiB
YAML
- name: Deploy Vaultwarden with Docker Compose and configure Caddy reverse proxy
|
|
hosts: edge
|
|
become: yes
|
|
vars_files:
|
|
- ../../services_config.yml
|
|
- ./vaultwarden_vars.yml
|
|
vars:
|
|
vaultwarden_subdomain: "{{ subdomains.vaultwarden }}"
|
|
vaultwarden_domain: "{{ vaultwarden_subdomain }}.{{ root_domain }}"
|
|
uptime_kuma_api_url: "https://{{ subdomains.uptime_kuma }}.{{ root_domain }}"
|
|
|
|
tasks:
|
|
- name: Create vaultwarden directory
|
|
file:
|
|
path: "{{ vaultwarden_dir }}"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: '0755'
|
|
|
|
- name: Create docker-compose.yml for vaultwarden
|
|
copy:
|
|
dest: "{{ vaultwarden_dir }}/docker-compose.yml"
|
|
content: |
|
|
version: "3"
|
|
services:
|
|
vaultwarden:
|
|
image: vaultwarden/server:latest
|
|
container_name: vaultwarden
|
|
restart: unless-stopped
|
|
ports:
|
|
- "{{ vaultwarden_port }}:80"
|
|
volumes:
|
|
- ./data:/data
|
|
environment:
|
|
WEBSOCKET_ENABLED: 'true'
|
|
DOMAIN: "https://{{ vaultwarden_domain }}"
|
|
SIGNUPS_ALLOWED: 'true'
|
|
LOG_FILE: /data/vaultwarden.log
|
|
|
|
- name: Deploy vaultwarden container with docker compose
|
|
command: docker compose up -d
|
|
args:
|
|
chdir: "{{ vaultwarden_dir }}"
|
|
|
|
- name: Create Fail2Ban filter for Vaultwarden
|
|
copy:
|
|
dest: /etc/fail2ban/filter.d/vaultwarden.local
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
content: |
|
|
[INCLUDES]
|
|
before = common.conf
|
|
|
|
[Definition]
|
|
failregex = ^.*?Username or password is incorrect\. Try again\. IP: <ADDR>\. Username:.*$
|
|
ignoreregex =
|
|
|
|
- name: Create Fail2Ban jail for Vaultwarden
|
|
copy:
|
|
dest: /etc/fail2ban/jail.d/vaultwarden.local
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
content: |
|
|
[vaultwarden]
|
|
enabled = true
|
|
port = http,https
|
|
filter = vaultwarden
|
|
logpath = {{ vaultwarden_data_dir }}/vaultwarden.log
|
|
maxretry = 10
|
|
findtime = 10m
|
|
bantime = 1h
|
|
|
|
- name: Restart fail2ban to apply changes
|
|
systemd:
|
|
name: fail2ban
|
|
state: restarted
|
|
|
|
- name: Publish Vaultwarden through Caddy
|
|
ansible.builtin.include_role:
|
|
name: caddy_site
|
|
vars:
|
|
caddy_site_name: vaultwarden
|
|
caddy_site_domain: "{{ vaultwarden_domain }}"
|
|
caddy_site_upstream: "localhost:{{ vaultwarden_port }}"
|
|
|
|
# ═════════════════════════════════════════════════════════════════════════
|
|
# DEPRECATED — Uptime Kuma was decommissioned on 2026-09-11.
|
|
#
|
|
# Every task below is inert: uptime_kuma_enabled is false in
|
|
# group_vars/all/main.yml, so they all skip and the deployment above still
|
|
# runs normally. Kept because the health-check logic is the durable part —
|
|
# when a replacement exists, rewire the push transport and flip the flag.
|
|
#
|
|
# What was being monitored: archive/uptime_kuma/MONITORS.md
|
|
# ═════════════════════════════════════════════════════════════════════════
|
|
- name: Create Uptime Kuma monitor setup script for Vaultwarden
|
|
when: uptime_kuma_enabled | default(false)
|
|
delegate_to: localhost
|
|
become: no
|
|
copy:
|
|
dest: /tmp/setup_vaultwarden_monitor.py
|
|
content: |
|
|
#!/usr/bin/env python3
|
|
import sys
|
|
import traceback
|
|
import yaml
|
|
from uptime_kuma_api import UptimeKumaApi, MonitorType
|
|
|
|
try:
|
|
# Load configs
|
|
with open('/tmp/ansible_config.yml', 'r') as f:
|
|
config = yaml.safe_load(f)
|
|
|
|
url = config['uptime_kuma_url']
|
|
username = config['username']
|
|
password = config['password']
|
|
monitor_url = config['monitor_url']
|
|
monitor_name = config['monitor_name']
|
|
|
|
# Connect to Uptime Kuma
|
|
api = UptimeKumaApi(url, timeout=30)
|
|
api.login(username, password)
|
|
|
|
# Get all monitors
|
|
monitors = api.get_monitors()
|
|
|
|
# Find or create "services" group
|
|
group = next((m for m in monitors if m.get('name') == 'services' and m.get('type') == 'group'), None)
|
|
if not group:
|
|
group_result = api.add_monitor(type='group', name='services')
|
|
# Refresh to get the group with id
|
|
monitors = api.get_monitors()
|
|
group = next((m for m in monitors if m.get('name') == 'services' and m.get('type') == 'group'), None)
|
|
|
|
# Check if monitor already exists
|
|
existing_monitor = None
|
|
for monitor in monitors:
|
|
if monitor.get('name') == monitor_name:
|
|
existing_monitor = monitor
|
|
break
|
|
|
|
# Get ntfy notification ID
|
|
notifications = api.get_notifications()
|
|
ntfy_notification_id = None
|
|
for notif in notifications:
|
|
if notif.get('type') == 'ntfy':
|
|
ntfy_notification_id = notif.get('id')
|
|
break
|
|
|
|
if existing_monitor:
|
|
print(f"Monitor '{monitor_name}' already exists (ID: {existing_monitor['id']})")
|
|
print("Skipping - monitor already configured")
|
|
else:
|
|
print(f"Creating monitor '{monitor_name}'...")
|
|
api.add_monitor(
|
|
type=MonitorType.HTTP,
|
|
name=monitor_name,
|
|
url=monitor_url,
|
|
parent=group['id'],
|
|
interval=60,
|
|
maxretries=3,
|
|
retryInterval=60,
|
|
notificationIDList={ntfy_notification_id: True} if ntfy_notification_id else {}
|
|
)
|
|
|
|
api.disconnect()
|
|
print("SUCCESS")
|
|
|
|
except Exception as e:
|
|
error_msg = str(e) if str(e) else repr(e)
|
|
print(f"ERROR: {error_msg}", file=sys.stderr)
|
|
traceback.print_exc(file=sys.stderr)
|
|
sys.exit(1)
|
|
mode: '0755'
|
|
|
|
- name: Create temporary config for monitor setup
|
|
when: uptime_kuma_enabled | default(false)
|
|
delegate_to: localhost
|
|
become: no
|
|
copy:
|
|
dest: /tmp/ansible_config.yml
|
|
content: |
|
|
uptime_kuma_url: "{{ uptime_kuma_api_url }}"
|
|
username: "{{ uptime_kuma_username }}"
|
|
password: "{{ uptime_kuma_password }}"
|
|
monitor_url: "https://{{ vaultwarden_domain }}/alive"
|
|
monitor_name: "Vaultwarden"
|
|
mode: '0644'
|
|
|
|
- name: Run Uptime Kuma monitor setup
|
|
when: uptime_kuma_enabled | default(false)
|
|
command: python3 /tmp/setup_vaultwarden_monitor.py
|
|
delegate_to: localhost
|
|
become: no
|
|
register: monitor_setup
|
|
changed_when: "'SUCCESS' in monitor_setup.stdout"
|
|
ignore_errors: yes
|
|
|
|
- name: Clean up temporary files
|
|
when: uptime_kuma_enabled | default(false)
|
|
delegate_to: localhost
|
|
become: no
|
|
file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /tmp/setup_vaultwarden_monitor.py
|
|
- /tmp/ansible_config.yml
|
|
|