Add playbooks/ntfy.yml

This commit is contained in:
Lorentz Administrator 2026-03-09 23:28:43 -04:00
parent 1d1179c009
commit 734ee9bf88

73
playbooks/ntfy.yml Normal file
View file

@ -0,0 +1,73 @@
- name: Deploy ntfy
hosts: docker_hosts
become: true
vars:
stack_dir: /opt/stacks/ntfy
pre_tasks:
- name: Fail if fqdn is not set
fail:
msg: "fqdn is required. Pass it via -e fqdn=..."
when: fqdn is not defined or fqdn | length == 0
tasks:
- name: Create stack directory
ansible.builtin.file:
path: "{{ stack_dir }}"
state: directory
mode: '0755'
- name: Ensure pangolin network exists
community.docker.docker_network:
name: pangolin
state: present
- name: Deploy compose.yml
ansible.builtin.copy:
dest: "{{ stack_dir }}/compose.yml"
mode: '0644'
content: |
services:
ntfy:
image: binwiederhier/ntfy:latest
container_name: ntfy
restart: unless-stopped
command: serve
environment:
NTFY_BASE_URL: https://{{ fqdn }}
NTFY_BEHIND_PROXY: "true"
NTFY_CACHE_FILE: /var/cache/ntfy/cache.db
NTFY_AUTH_FILE: /var/lib/ntfy/auth.db
NTFY_AUTH_DEFAULT_ACCESS: deny-all
NTFY_ATTACHMENT_CACHE_DIR: /var/cache/ntfy/attachments
volumes:
- ntfy-cache:/var/cache/ntfy
- ntfy-auth:/var/lib/ntfy
expose:
- "80"
healthcheck:
test: ["CMD-SHELL", "wget -q --tries=1 http://localhost:80/v1/health -O - | grep -Eo '\"healthy\"\\s*:\\s*true' || exit 1"]
interval: 60s
timeout: 10s
retries: 3
start_period: 10s
networks:
- pangolin
volumes:
ntfy-cache:
ntfy-auth:
networks:
pangolin:
external: true
- name: Pull images
community.docker.docker_compose_v2_pull:
project_src: "{{ stack_dir }}"
- name: Deploy stack
community.docker.docker_compose_v2:
project_src: "{{ stack_dir }}"
state: present