diff --git a/_ansible/inventory/group_vars/all/main.yml b/_ansible/inventory/group_vars/all/main.yml index 8b84ce9..6189e24 100644 --- a/_ansible/inventory/group_vars/all/main.yml +++ b/_ansible/inventory/group_vars/all/main.yml @@ -10,5 +10,6 @@ mailer: services_path: /opt/services/ -caddy_config_path: "{{ (services_path, 'caddy', 'config', 'conf.d') | path_join }}" +caddy_path: "{{ (services_path, 'caddy') | path_join }}" +caddy_config_path: "{{ (caddy_path, 'config', 'conf.d') | path_join }}" managed_sites: [] diff --git a/_ansible/node002.yml b/_ansible/node002.yml index 56bf8ec..b47b2b6 100644 --- a/_ansible/node002.yml +++ b/_ansible/node002.yml @@ -9,5 +9,6 @@ - homebox - influxdb - umami + - uptime-kuma - watchtower - wiki-js diff --git a/_ansible/roles/uptime-kuma/tasks/main.yml b/_ansible/roles/uptime-kuma/tasks/main.yml new file mode 100644 index 0000000..046fe57 --- /dev/null +++ b/_ansible/roles/uptime-kuma/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: Deploy {{ svc.name }} + tags: + - uptime-kuma + - status + block: + - import_tasks: deploy-common-service.yml diff --git a/_ansible/roles/uptime-kuma/vars/main.yml b/_ansible/roles/uptime-kuma/vars/main.yml new file mode 100644 index 0000000..b79d309 --- /dev/null +++ b/_ansible/roles/uptime-kuma/vars/main.yml @@ -0,0 +1,14 @@ +svc: + domain: "status.serguzim.me" + name: uptime-kuma + port: 3001 + +compose: + watchtower: true + image: louislam/uptime-kuma:1 + volumes: + - data:/app/data + file: + volumes: + data: + diff --git a/_ansible/tasks/deploy-common-service.yml b/_ansible/tasks/deploy-common-service.yml index d2ce6df..34f0028 100644 --- a/_ansible/tasks/deploy-common-service.yml +++ b/_ansible/tasks/deploy-common-service.yml @@ -1,6 +1,7 @@ - import_tasks: steps/create-service-directory.yml - import_tasks: steps/template-docker-compose.yml - import_tasks: steps/template-service-env.yml + when: compose.env|default(False) == True - include_tasks: steps/template-site-config.yml when: svc.domain is defined - import_tasks: steps/start-service.yml diff --git a/_ansible/tasks/steps/template-site-config.yml b/_ansible/tasks/steps/template-site-config.yml index e98659d..8f99d2b 100644 --- a/_ansible/tasks/steps/template-site-config.yml +++ b/_ansible/tasks/steps/template-site-config.yml @@ -7,3 +7,9 @@ - name: Register caddy site ansible.builtin.set_fact: managed_sites: "{{ managed_sites + [svc.domain + '.conf'] }}" + +- name: Reload caddy + ansible.builtin.command: + cmd: docker compose exec app sh -c "caddy validate --config /etc/caddy/Caddyfile && caddy reload --config /etc/caddy/Caddyfile" + chdir: "{{ caddy_path }}" + changed_when: True diff --git a/backup/.env b/backup/.env index 3932a35..ab7f857 100644 --- a/backup/.env +++ b/backup/.env @@ -1,4 +1,5 @@ HC_UID= +UPTIME_KUMA_TOKEN= RESTIC_REPOSITORY= RESTIC_PASSWORD= diff --git a/backup/backup.sh b/backup/backup.sh index d552e74..2580614 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -10,6 +10,7 @@ set +a hc_url="https://hc-ping.com/$HC_UID" curl -fsSL --retry 3 "$hc_url/start" >/dev/null +duration_start=$(date +%s) BACKUP_LOCATION="/tmp/backup-misc" @@ -57,4 +58,8 @@ time _backup_prepare_mailcow >/tmp/backup-mailcow.log || _hc_fail cd /opt/services/backup/ docker compose run --rm backup || _hc_fail +duration_end=$(date +%s) curl -fsSL --retry 3 "$hc_url" + +duration=$((duration_end - duration_start)) +curl -fsSL --retry 3 "https://status.serguzim.me/api/push/$UPTIME_KUMA_TOKEN?status=up&msg=OK&ping=${duration}000"