Add Uptime Kuma role.
This commit is contained in:
parent
826f1507b9
commit
de1fd0454a
7 changed files with 118 additions and 0 deletions
5
env.yml
5
env.yml
|
@ -46,6 +46,7 @@ projects:
|
|||
- searxng
|
||||
- synapse
|
||||
- syncthing
|
||||
- uptime-kuma
|
||||
- vaultwarden
|
||||
|
||||
|
||||
|
@ -53,6 +54,7 @@ projects_to_backup:
|
|||
- etebase
|
||||
- hedgedoc
|
||||
- synapse
|
||||
- uptime-kuma
|
||||
- vaultwarden
|
||||
|
||||
|
||||
|
@ -85,6 +87,7 @@ ports:
|
|||
syncthing_webui: 8384
|
||||
syncthing_tcp: 5432
|
||||
syncthing_udp: 22000
|
||||
uptime_kuma: 3001
|
||||
vaultwarden: 8081
|
||||
|
||||
|
||||
|
@ -102,6 +105,7 @@ users:
|
|||
syncthing: 1001
|
||||
syncthing_discosrv: 1002
|
||||
syncthing_relaysrv: 1003
|
||||
uptime_kuma: 1006
|
||||
vaultwarden: 1000
|
||||
|
||||
|
||||
|
@ -114,6 +118,7 @@ volumes:
|
|||
synapse_datadir: /mnt/synapsedata
|
||||
synapse_postgres_datadir: /mnt/synapsepgdata
|
||||
syncthing_datadir: "{{ cifs_mounts['syncthing']['path'] }}"
|
||||
uptime_kuma_datadir: /mnt/uptimekumadata
|
||||
vaultwarden_datadir: /mnt/vwdata
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
upstream vaultwarden-default {
|
||||
zone vaultwarden-default 64k;
|
||||
|
|
29
roles/uptime-kuma/tasks/backup.yml
Normal file
29
roles/uptime-kuma/tasks/backup.yml
Normal 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 }}"
|
9
roles/uptime-kuma/tasks/main.yml
Normal file
9
roles/uptime-kuma/tasks/main.yml
Normal 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
|
45
roles/uptime-kuma/tasks/update.yml
Normal file
45
roles/uptime-kuma/tasks/update.yml
Normal 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 }}"
|
12
roles/uptime-kuma/templates/docker-compose.yaml
Normal file
12
roles/uptime-kuma/templates/docker-compose.yaml
Normal 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
|
1
roles/uptime-kuma/vars/main.yml
Normal file
1
roles/uptime-kuma/vars/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
uptime_kuma_project_dir: "{{ docker_projects_dir }}/{{ role_name }}"
|
Loading…
Reference in a new issue