Files
n0mad1k 3542913689 LAN/local deployment support, OS compat, Cloudflare Tunnel
- Smart TLS: skip certbot for IPs/.local/.lan, self-signed with SAN,
  HSTS max-age=0 for self-signed certs, split LAN vs public messages
- Dynamic PHP: versionless meta-packages, runtime detection via php_ver fact
- Vaultwarden: fail-fast on armv7l (32-bit ARM not supported upstream)
- Module prompts: accept IPs for matrix/cloud/vault/media, hard error
  on email with IP, all_in_one skips certbot email for LAN
- Matrix: skip matrix. prefix strip for IPs, warn about immutable server_name
- OS family guards: ansible_os_family == Debian on all apt tasks
- SSH key path: expanduser().resolve() on user-provided key paths
- Cloudflare Tunnel: post-deploy script (setup-tunnel.sh) using CF API
  token — no browser auth needed, creates tunnel + credentials + DNS + systemd

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:27:12 -04:00

169 lines
5.1 KiB
YAML

---
# All-in-One deployment — multiple services on a single server
# Installs nginx as reverse proxy with TLS termination via Certbot,
# then deploys selected services behind vhost routing.
#
# NOTE: This playbook includes task files directly rather than
# importing full playbooks, to allow conditional composition.
# NOTE: Email (MIAB) is excluded — it manages its own nginx/DNS/TLS.
- name: All-in-One Privacy Server
hosts: all
become: true
vars:
base_domain: "{{ domain }}"
selected_services: "{{ services | default([]) }}"
certbot_email: "{{ certbot_email | default('') }}"
target_host: "{{ target_host | default('localhost') }}"
tasks:
# ─── Base: Nginx + Certbot ────────────────────────────────────────
- name: Install nginx and certbot
apt:
name:
- nginx
- certbot
- python3-certbot-nginx
state: present
when: ansible_os_family == "Debian"
- name: Remove default nginx site
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: reload nginx
- name: Allow HTTP/HTTPS through UFW
ufw:
rule: allow
port: "{{ item }}"
proto: tcp
loop:
- "80"
- "443"
# ─── Deploy Individual Services (task files, not full playbooks) ──
# Matrix
- name: Deploy Matrix — Synapse
include_tasks: "{{ playbook_dir }}/../matrix/tasks/synapse.yml"
when: "'matrix' in selected_services"
- name: Deploy Matrix — Element Web
include_tasks: "{{ playbook_dir }}/../matrix/tasks/element.yml"
when: "'matrix' in selected_services and (matrix_element_web | default(true) | bool)"
- name: Deploy Matrix — Nginx vhost
include_tasks: "{{ playbook_dir }}/../matrix/tasks/nginx.yml"
when: "'matrix' in selected_services"
- name: Deploy Matrix user creation script
template:
src: "{{ playbook_dir }}/../common/templates/add-matrix-user.sh.j2"
dest: /root/Tools/add-matrix-user.sh
mode: "0700"
when: "'matrix' in selected_services"
# WireGuard VPN
- name: Deploy WireGuard — Install
include_tasks: "{{ playbook_dir }}/../vpn/tasks/install.yml"
when: "'vpn' in selected_services"
- name: Deploy WireGuard — Configure
include_tasks: "{{ playbook_dir }}/../vpn/tasks/configure.yml"
when: "'vpn' in selected_services"
# Pi-hole DNS
- name: Deploy Pi-hole — Install
include_tasks: "{{ playbook_dir }}/../dns/tasks/install.yml"
when: "'dns' in selected_services"
- name: Deploy Pi-hole — Configure
include_tasks: "{{ playbook_dir }}/../dns/tasks/configure.yml"
when: "'dns' in selected_services"
# Nextcloud
- name: Deploy Nextcloud — Install
include_tasks: "{{ playbook_dir }}/../cloud/tasks/install.yml"
when: "'cloud' in selected_services"
- name: Deploy Nextcloud — Configure
include_tasks: "{{ playbook_dir }}/../cloud/tasks/configure.yml"
when: "'cloud' in selected_services"
- name: Deploy Nextcloud — Nginx vhost
include_tasks: "{{ playbook_dir }}/../cloud/tasks/nginx.yml"
when: "'cloud' in selected_services"
# Vaultwarden
- name: Deploy Vaultwarden — Install
include_tasks: "{{ playbook_dir }}/../vault/tasks/install.yml"
when: "'vault' in selected_services"
- name: Deploy Vaultwarden — Configure
include_tasks: "{{ playbook_dir }}/../vault/tasks/configure.yml"
when: "'vault' in selected_services"
- name: Deploy Vaultwarden — Nginx vhost
include_tasks: "{{ playbook_dir }}/../vault/tasks/nginx.yml"
when: "'vault' in selected_services"
# Jellyfin
- name: Deploy Jellyfin — Install
include_tasks: "{{ playbook_dir }}/../media/tasks/install.yml"
when: "'media' in selected_services"
- name: Deploy Jellyfin — Configure
include_tasks: "{{ playbook_dir }}/../media/tasks/configure.yml"
when: "'media' in selected_services"
- name: Deploy Jellyfin — Nginx vhost
include_tasks: "{{ playbook_dir }}/../media/tasks/nginx.yml"
when: "'media' in selected_services"
handlers:
- name: reload nginx
service:
name: nginx
state: reloaded
- name: restart synapse
service:
name: matrix-synapse
state: restarted
- name: restart php-fpm
service:
name: "php{{ php_ver | default('8.2') }}-fpm"
state: restarted
- name: restart mariadb
service:
name: mariadb
state: restarted
- name: restart redis
service:
name: redis-server
state: restarted
- name: restart vaultwarden
service:
name: vaultwarden
state: restarted
- name: restart jellyfin
service:
name: jellyfin
state: restarted
- name: restart pihole-FTL
service:
name: pihole-FTL
state: restarted
- name: restart sshd
service:
name: sshd
state: restarted