Add watchtower to ansible

This commit is contained in:
Tobias Reisinger 2023-06-16 13:15:45 +02:00
parent 753682aa86
commit 5908976abc
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
10 changed files with 64 additions and 49 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ gitea/
caddy/config/conf.002.d/git.serguzim.me.conf caddy/config/conf.002.d/git.serguzim.me.conf
umami/ umami/
caddy/config/conf.002.d/analytics.serguzim.me.conf caddy/config/conf.002.d/analytics.serguzim.me.conf
watchtower/

View file

@ -1,4 +1,4 @@
compose_default_file: compose_file_main:
services: services:
app: app:
image: "{{ compose.image }}" image: "{{ compose.image }}"
@ -13,8 +13,18 @@ compose_default_file:
apps: apps:
external: true external: true
compose_env_file: compose_file_env:
services: services:
app: app:
env_file: env_file:
- service.env - service.env
compose_file_ports:
services:
app:
ports: "{{ compose.ports }}"
compose_file_volumes:
services:
app:
volumes: "{{ compose.volumes }}"

View file

@ -4,5 +4,10 @@ postgres:
host: db.serguzim.me host: db.serguzim.me
port: 5432 port: 5432
mailer:
host: mail.serguzim.me
port: 587
services_path: /opt/services/ services_path: /opt/services/
caddy_config_path: "{{ (services_path, 'caddy', 'config', 'conf.d') | path_join }}" caddy_config_path: "{{ (services_path, 'caddy', 'config', 'conf.d') | path_join }}"

View file

@ -10,3 +10,4 @@
- acme-dns - acme-dns
- gitea - gitea
- umami - umami
- watchtower

View file

@ -5,3 +5,4 @@
- acme-dns - acme-dns
- gitea - gitea
- umami - umami
- watchtower

View file

@ -16,11 +16,8 @@ svc:
compose: compose:
watchtower: true watchtower: true
image: joohoi/acme-dns image: joohoi/acme-dns
file: ports:
services: - "53:53"
app: - "53:53/udp"
ports: volumes:
- "53:53" - ./config:/etc/acme-dns:ro
- "53:53/udp"
volumes:
- ./config:/etc/acme-dns:ro

View file

@ -78,16 +78,14 @@ compose:
watchtower: true watchtower: true
image: gitea/gitea:1.19 image: gitea/gitea:1.19
env: true env: true
volumes:
- data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "{{ svc.ssh_port }}:{{ svc.ssh_port }}"
- "{{ svc.ssh_port_alt }}:{{ svc.ssh_port }}"
file: file:
services:
app:
volumes:
- data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "{{ svc.ssh_port }}:{{ svc.ssh_port }}"
- "{{ svc.ssh_port_alt }}:{{ svc.ssh_port }}"
volumes: volumes:
data: data:

View file

@ -1,6 +1,16 @@
{% set compose_file = compose.file | default({}) %} {%- set compose_file = compose.file | default({}) -%}
{% set compose_file = compose_default_file | combine(compose_file, recursive=True) %} {%- set compose_file = compose_file_main | combine(compose_file, recursive=True) -%}
{% if compose.env | default(False) %}
{% set compose_file = compose_file | combine(compose_env_file, recursive=True) %} {%- if compose.env | default(False) -%}
{% endif %} {%- set compose_file = compose_file | combine(compose_file_env, recursive=True) -%}
{%- endif -%}
{%- if compose.ports | default(False) -%}
{%- set compose_file = compose_file | combine(compose_file_ports, recursive=True) -%}
{%- endif -%}
{%- if compose.volumes | default(False) -%}
{%- set compose_file = compose_file | combine(compose_file_volumes, recursive=True) -%}
{%- endif -%}
{{ compose_file | to_nice_yaml }} {{ compose_file | to_nice_yaml }}

View file

@ -1,14 +0,0 @@
WATCHTOWER_LABEL_ENABLE=true
WATCHTOWER_CLEANUP=true
WATCHTOWER_SCHEDULE="0 27 20 * * *"
WATCHTOWER_NOTIFICATIONS=email
WATCHTOWER_NOTIFICATION_EMAIL_FROM=watchtower@serguzim.me
WATCHTOWER_NOTIFICATION_EMAIL_TO=tobias@msrg.cc
WATCHTOWER_NOTIFICATION_EMAIL_SERVER=mail.serguzim.me
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=watchtower@serguzim.me
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=
WATCHTOWER_NOTIFICATION_EMAIL_DELAY=5
#WATCHTOWER_RUN_ONCE=true

View file

@ -1,12 +1,18 @@
version: "3" networks:
apps:
external: true
services: services:
watchtower: app:
image: containrrr/watchtower env_file:
restart: always - service.env
env_file: hostname: portalo
- .env image: containerrr/watchtower
- .secret.env labels:
hostname: ${HOSTNAME} com.centurylinklabs.watchtower.enable: false
volumes: networks:
- /var/run/docker.sock:/var/run/docker.sock apps:
aliases:
- watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock