add ntfy webapp service

This commit is contained in:
counterweight 2025-10-19 00:37:15 +02:00
parent 89688b0ef2
commit 5ddc98b1eb
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,71 @@
- name: Deploy ntfy-emergency-app with Docker Compose and configure Caddy reverse proxy
hosts: vipy
become: yes
vars_files:
- ../../infra_vars.yml
- ./ntfy_emergency_app_vars.yml
vars:
ntfy_emergency_app_domain: "{{ ntfy_emergency_app_subdomain }}.{{ root_domain }}"
tasks:
- name: Create ntfy-emergency-app directory
file:
path: "{{ ntfy_emergency_app_dir }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
- name: Create docker-compose.yml for ntfy-emergency-app
copy:
dest: "{{ ntfy_emergency_app_dir }}/docker-compose.yml"
content: |
version: "3"
services:
ntfy-emergency-app:
image: ghcr.io/pmartincalvo/ntfy-emergency-app:latest
container_name: ntfy-emergency-app
restart: unless-stopped
ports:
- "{{ ntfy_emergency_app_port }}:3000"
environment:
NTFY_TOPIC: "{{ ntfy_emergency_app_topic }}"
NTFY_URL: "{{ ntfy_emergency_app_ntfy_url }}"
NTFY_USER: "{{ ntfy_emergency_app_ntfy_user }}"
NTFY_PASSWORD: "{{ ntfy_emergency_app_ntfy_password }}"
UI_MESSAGE: "{{ ntfy_emergency_app_ui_message }}"
- name: Deploy ntfy-emergency-app container with docker compose
command: docker compose up -d
args:
chdir: "{{ ntfy_emergency_app_dir }}"
- name: Ensure Caddy sites-enabled directory exists
file:
path: "{{ caddy_sites_dir }}"
state: directory
owner: root
group: root
mode: '0755'
- name: Ensure Caddyfile includes import directive for sites-enabled
lineinfile:
path: /etc/caddy/Caddyfile
line: 'import sites-enabled/*'
insertafter: EOF
state: present
backup: yes
- name: Create Caddy reverse proxy configuration for ntfy-emergency-app
copy:
dest: "{{ caddy_sites_dir }}/ntfy-emergency-app.conf"
content: |
{{ ntfy_emergency_app_domain }} {
reverse_proxy localhost:{{ ntfy_emergency_app_port }}
}
owner: root
group: root
mode: '0644'
- name: Reload Caddy to apply new config
command: systemctl reload caddy

View file

@ -0,0 +1,19 @@
# General
ntfy_emergency_app_dir: /opt/ntfy-emergency-app
ntfy_emergency_app_port: 3000
# Caddy
caddy_sites_dir: /etc/caddy/sites-enabled
ntfy_emergency_app_subdomain: avisame
# ntfy configuration
ntfy_emergency_app_topic: "emergencia"
ntfy_emergency_app_ntfy_url: "https://ntfy.contrapeso.xyz"
ntfy_emergency_app_ntfy_user: "counterweight"
ntfy_emergency_app_ntfy_password: "superntfyme"
ntfy_emergency_app_ui_message: "Leave Pablo a message, he will respond as soon as possible"
# Remote access
remote_host: "{{ groups['vipy'][0] }}"
remote_user: "{{ hostvars[remote_host]['ansible_user'] }}"
remote_key_file: "{{ hostvars[remote_host]['ansible_ssh_private_key_file'] | default('') }}"