Add Uptime Kuma role.

This commit is contained in:
Viyurz 2024-03-08 16:35:07 +01:00
parent 826f1507b9
commit de1fd0454a
Signed by: Viyurz
SSH key fingerprint: SHA256:IskOHTmhHSJIvAt04N6aaxd5SZCVWW1Guf9tEcxIMj8
7 changed files with 118 additions and 0 deletions

View file

@ -46,6 +46,7 @@ projects:
- searxng - searxng
- synapse - synapse
- syncthing - syncthing
- uptime-kuma
- vaultwarden - vaultwarden
@ -53,6 +54,7 @@ projects_to_backup:
- etebase - etebase
- hedgedoc - hedgedoc
- synapse - synapse
- uptime-kuma
- vaultwarden - vaultwarden
@ -85,6 +87,7 @@ ports:
syncthing_webui: 8384 syncthing_webui: 8384
syncthing_tcp: 5432 syncthing_tcp: 5432
syncthing_udp: 22000 syncthing_udp: 22000
uptime_kuma: 3001
vaultwarden: 8081 vaultwarden: 8081
@ -102,6 +105,7 @@ users:
syncthing: 1001 syncthing: 1001
syncthing_discosrv: 1002 syncthing_discosrv: 1002
syncthing_relaysrv: 1003 syncthing_relaysrv: 1003
uptime_kuma: 1006
vaultwarden: 1000 vaultwarden: 1000
@ -114,6 +118,7 @@ volumes:
synapse_datadir: /mnt/synapsedata synapse_datadir: /mnt/synapsedata
synapse_postgres_datadir: /mnt/synapsepgdata synapse_postgres_datadir: /mnt/synapsepgdata
syncthing_datadir: "{{ cifs_mounts['syncthing']['path'] }}" syncthing_datadir: "{{ cifs_mounts['syncthing']['path'] }}"
uptime_kuma_datadir: /mnt/uptimekumadata
vaultwarden_datadir: /mnt/vwdata vaultwarden_datadir: /mnt/vwdata

View file

@ -170,6 +170,23 @@ server {
} }
# Uptime Kuma
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name status.{{ domain }};
location / {
proxy_pass http://127.0.0.1:{{ ports['uptime_kuma'] }};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
# Vaultwarden # Vaultwarden
upstream vaultwarden-default { upstream vaultwarden-default {
zone vaultwarden-default 64k; zone vaultwarden-default 64k;

View file

@ -0,0 +1,29 @@
- name:
become: true
block:
- name: Backup SQLite database
command:
cmd: |
sqlite3
"{{ volumes['uptime_kuma_datadir'] }}/kuma.db"
".backup {{ volumes['uptime_kuma_datadir'] }}/kuma-backup.db"
- name: Create borg backup
command:
cmd: |
borg create
--compression=lzma
"{{ borg_repodir }}::{{ role_name }}-{now:%Y-%m-%d_%H-%M-%S}"
{{ volumes['uptime_kuma_datadir'] }}/kuma-backup.db
environment:
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"
- name: Prune borg repository
command:
cmd: |
borg prune
--glob-archives='{{ role_name }}-*'
{{ borg_prune_options }}
{{ borg_repodir }}
environment:
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"

View file

@ -0,0 +1,9 @@
- name: Include backup tasks
include_tasks:
file: backup.yml
when: run_backup | default(false) | bool
- name: Include update tasks
include_tasks:
file: update.yml
when: run_update | default(false) | bool

View file

@ -0,0 +1,45 @@
- name: "Create {{ uptime_kuma_project_dir }} project directory"
file:
path: "{{ uptime_kuma_project_dir }}"
state: directory
- name: Template docker-compose.yaml to project directory
template:
src: docker-compose.yaml
dest: "{{ uptime_kuma_project_dir }}/docker-compose.yaml"
owner: "{{ ansible_env['USER'] }}"
group: "{{ ansible_env['USER'] }}"
mode: '640'
- name: "Create directory {{ volumes['uptime_kuma_datadir'] }} with correct permissions"
file:
path: "{{ volumes['uptime_kuma_datadir'] }}"
state: directory
owner: "{{ users['uptime_kuma'] + uid_shift }}"
group: "{{ users['uptime_kuma'] + uid_shift }}"
mode: '770'
become: true
- name: Pull project services
community.docker.docker_compose:
project_src: "{{ uptime_kuma_project_dir }}"
recreate: never
pull: true
debug: true
when: docker_pull_images | bool
register: uptime_kuma_docker_compose_pull_result
- name: Display pulled image(s) name
set_fact:
uptime_kuma_pulled_images: "{{ uptime_kuma_pulled_images | default([]) + [item.pulled_image.name] }}"
loop: "{{ uptime_kuma_docker_compose_pull_result['actions'] | default([]) | selectattr('pulled_image', 'defined') }}"
- name: Include backup tasks
include_tasks:
file: backup.yml
# Make a backup if we didn't already make one and we pulled a new image
when: not run_backup and uptime_kuma_pulled_images is defined
- name: Create/Restart project services
community.docker.docker_compose:
project_src: "{{ uptime_kuma_project_dir }}"

View file

@ -0,0 +1,12 @@
services:
uptime-kuma:
image: docker.io/louislam/uptime-kuma:alpine
container_name: uptime-kuma
restart: always
environment:
- PUID={{ users['uptime_kuma'] }}
- PGID={{ users['uptime_kuma'] }}
ports:
- 127.0.0.1:{{ ports['uptime_kuma'] }}:3001
volumes:
- {{ volumes['uptime_kuma_datadir' ] }}:/app/data

View file

@ -0,0 +1 @@
uptime_kuma_project_dir: "{{ docker_projects_dir }}/{{ role_name }}"