Add diun role

This commit is contained in:
Marty Oehme 2024-06-25 12:20:46 +02:00
parent b6f7934c5f
commit e8447a6289
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
7 changed files with 116 additions and 0 deletions

5
roles/diun/README.md Normal file
View file

@ -0,0 +1,5 @@
# diun
Monitor the deployed swarm containers for updates.
Will notify you when it found any update for any container.
Can (currently) notify you either through mail or on matrix.

View file

@ -0,0 +1,26 @@
---
diun_version: 4
diun_upstream_file_dir: "{{ docker_stack_files_dir }}/{{ stack_name }}"
diun_use_https: true
# the subdomain link diun will be reachable under
subdomain_alias: diun
diun_tz: Europe/Berlin
diun_log_level: info
diun_watch_swarm_by_default: true
diun_notif_mail_host: localhost
diun_notif_mail_port: 25
# diun_notif_mail_username: required for mail
# diun_notif_mail_password: required for mail
# diun_notif_mail_from: required for mail
# diun_notif_mail_to: required for mail
diun_notif_matrix_url: "https://matrix.org"
#diun_notif_matrix_user: required for matrix
#diun_notif_matrix_password: required for matrix
#diun_notif_matrix_roomid: required for matrix

10
roles/diun/meta/main.yml Normal file
View file

@ -0,0 +1,10 @@
---
galaxy_info:
author: Marty Oehme
description: Notify on any docker swarm container updates
license: GPL-3.0-only
min_ansible_version: "2.9"
galaxy_tags: []
dependencies:
- docker-swarm

12
roles/diun/tasks/main.yml Normal file
View file

@ -0,0 +1,12 @@
---
## install diun container
- name: Deploy diun to swarm
community.general.docker_stack:
name: "{{ stack_name }}"
state: present
prune: yes
compose:
- "{{ stack_compose }}"
become: true
tags:
- docker-swarm

View file

@ -0,0 +1,51 @@
version: '3.4'
services:
app:
image: crazymax/diun:latest
# healthcheck:
# test: ["CMD", "wget", "--spider", "-q", "127.0.0.1"]
# interval: 1m
# timeout: 10s
# retries: 3
# start_period: 1m
command: serve
volumes:
- "data:/data"
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
- "TZ={{ diun_tz }}"
- "LOG_LEVEL={{ diun_log_level }}"
- "LOG_JSON=false"
- "DIUN_WATCH_WORKERS=20"
- "DIUN_WATCH_SCHEDULE=0 */6 * * *"
- "DIUN_WATCH_JITTER=30s"
- "DIUN_PROVIDERS_SWARM=true"
- "DIUN_PROVIDERS_SWARM_WATCHBYDEFAULT={{ diun_watch_swarm_by_default }}"
{% if diun_notif_matrix_user is not undefined and not None and diun_notif_matrix_password is not undefined and not None and diun_notif_matrix_roomid is not undefined and not None %}
- "DIUN_NOTIF_MATRIX_HOMESERVERURL={{ diun_notif_matrix_url }}"
- "DIUN_NOTIF_MATRIX_USER={{ diun_notif_matrix_user }}"
- "DIUN_NOTIF_MATRIX_PASSWORD={{ diun_notif_matrix_password }}"
- "DIUN_NOTIF_MATRIX_ROOMID={{ diun_notif_matrix_roomid }}"
{% endif %}
{% if diun_notif_mail_username is not undefined and not None and diun_notif_mail_password is not undefined and not None and diun_notif_mail_from is not undefined and not None and diun_notif_mail_to is not undefined and not None %}
- "DIUN_NOTIF_MAIL_HOST={{ diun_notif_mail_host }}"
- "DIUN_NOTIF_MAIL_PORT={{ diun_notif_mail_port }}"
- "DIUN_NOTIF_MAIL_USERNAME={{ diun_notif_mail_username }}"
- "DIUN_NOTIF_MAIL_PASSWORD={{ diun_notif_mail_password }}"
- "DIUN_NOTIF_MAIL_FROM={{ diun_notif_mail_from }}"
- "DIUN_NOTIF_MAIL_TO={{ diun_notif_mail_to }}"
{% endif %}
# deploy:
# mode: replicated
# replicas: 1
# placement:
# constraints:
# - node.role == manager
volumes:
data:
networks:
"{{ docker_swarm_public_network_name }}":
external: true

6
roles/diun/vars/main.yml Normal file
View file

@ -0,0 +1,6 @@
---
stack_name: diun
stack_image: "crazymax/diun"
stack_compose: "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}"

View file

@ -86,3 +86,9 @@
tags:
- ntfy
- never
- name: Install diun
import_role:
role: diun
tags:
- diun