Add ntfy role

Installs and configures the ntfysh server to enable notifications.
This commit is contained in:
Marty Oehme 2022-01-23 13:54:56 +01:00
parent 1e0643352d
commit 32b1b13ef4
Signed by: Marty
GPG key ID: B7538B8F50A1C800
11 changed files with 253 additions and 0 deletions

38
roles/ntfy/tasks/main.yml Normal file
View file

@ -0,0 +1,38 @@
---
- name: Ensure target directory exists
ansible.builtin.file:
path: "{{ ntfy_upstream_file_dir }}"
state: directory
mode: '0755'
become: yes
- name: Move ntfy configuration file to target dir
ansible.builtin.template:
src: "server.yml.j2"
dest: "{{ ntfy_upstream_file_dir }}/server.yml"
become: yes
notify: "update ntfy upstream"
## install ntfy container
- name: Check upstream status
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl localhost:2019/id/{{ stack_name }}_upstream/
register: result
changed_when: (result.stdout | from_json) != (lookup('template', 'upstream.json.j2') | from_yaml)
become: yes
notify: "update ntfy upstream"
- name: Deploy ntfy to swarm
community.general.docker_stack:
name: "{{ stack_name }}"
state: present
prune: yes
compose:
- "{{ stack_compose }}"
become: yes
tags:
- docker-swarm
notify: "update ntfy upstream"