From c472411801e1def736ed1bb21c195ea6442ed368 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 21 Apr 2024 18:11:39 +0100 Subject: [PATCH] Deploy uptime-kuma --- ansible/host_vars/pve-docker/main.yml | 1 + ansible/main.yml | 1 + ansible/roles/traefik/defaults/main.yml | 1 + .../files/file-provider-uptime-kuma.yml | 10 ++++++++++ ansible/roles/traefik/tasks/main.yml | 10 ++++++++++ .../roles/uptime_kuma/files/docker-compose.yml | 18 ++++++++++++++++++ ansible/roles/uptime_kuma/handlers/main.yml | 4 ++++ ansible/roles/uptime_kuma/tasks/main.yml | 17 +++++++++++++++++ terraform/jakehoward.tech.tf | 8 ++++++++ 9 files changed, 70 insertions(+) create mode 100644 ansible/roles/traefik/files/file-provider-uptime-kuma.yml create mode 100644 ansible/roles/uptime_kuma/files/docker-compose.yml create mode 100644 ansible/roles/uptime_kuma/handlers/main.yml create mode 100644 ansible/roles/uptime_kuma/tasks/main.yml diff --git a/ansible/host_vars/pve-docker/main.yml b/ansible/host_vars/pve-docker/main.yml index f27a53e..bfa890c 100644 --- a/ansible/host_vars/pve-docker/main.yml +++ b/ansible/host_vars/pve-docker/main.yml @@ -4,6 +4,7 @@ traefik_provider_jellyfin: true traefik_provider_homeassistant: true traefik_provider_grafana: true traefik_provider_dokku: true +traefik_provider_uptime_kuma: true with_fail2ban: true diff --git a/ansible/main.yml b/ansible/main.yml index af7910a..8a8ce5e 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -96,6 +96,7 @@ - hosts: forrest roles: - forrest + - uptime_kuma - pve_nebula_route - pve_tailscale_route diff --git a/ansible/roles/traefik/defaults/main.yml b/ansible/roles/traefik/defaults/main.yml index eb31b28..2827db6 100644 --- a/ansible/roles/traefik/defaults/main.yml +++ b/ansible/roles/traefik/defaults/main.yml @@ -2,5 +2,6 @@ traefik_provider_jellyfin: false traefik_provider_homeassistant: false traefik_provider_grafana: false traefik_provider_dokku: false +traefik_provider_uptime_kuma: false with_fail2ban: false diff --git a/ansible/roles/traefik/files/file-provider-uptime-kuma.yml b/ansible/roles/traefik/files/file-provider-uptime-kuma.yml new file mode 100644 index 0000000..5019052 --- /dev/null +++ b/ansible/roles/traefik/files/file-provider-uptime-kuma.yml @@ -0,0 +1,10 @@ +http: + routers: + router-uptime-kuma: + rule: Host(`uptime.jakehoward.tech`) + service: service-uptime-kuma + services: + service-uptime-kuma: + loadBalancer: + servers: + - url: http://{{ pve_hosts.forrest.ip }}:3001 diff --git a/ansible/roles/traefik/tasks/main.yml b/ansible/roles/traefik/tasks/main.yml index d62fdcd..11ff184 100644 --- a/ansible/roles/traefik/tasks/main.yml +++ b/ansible/roles/traefik/tasks/main.yml @@ -101,6 +101,16 @@ when: traefik_provider_dokku become: true +- name: Install dokku provider + template: + src: files/file-provider-uptime-kuma.yml + dest: /opt/traefik/traefik/conf/uptime-kuma.yml + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + notify: restart traefik + when: traefik_provider_uptime_kuma + become: true + - name: logrotate config template: src: files/logrotate.conf diff --git a/ansible/roles/uptime_kuma/files/docker-compose.yml b/ansible/roles/uptime_kuma/files/docker-compose.yml new file mode 100644 index 0000000..bc98ebe --- /dev/null +++ b/ansible/roles/uptime_kuma/files/docker-compose.yml @@ -0,0 +1,18 @@ +version: "2.3" + +services: + uptime-kuma: + image: louislam/uptime-kuma:1.23.11-alpine + environment: + - TZ={{ timezone }} + - PUID={{ docker_user.id }} + - PGID={{ docker_user.id }} + ports: + - "{{ pve_hosts.forrest.ip }}:3001:3001" + volumes: + - "{{ app_data_dir }}/uptime-kuma:/app/data" + restart: unless-stopped + +networks: + default: + enable_ipv6: true diff --git a/ansible/roles/uptime_kuma/handlers/main.yml b/ansible/roles/uptime_kuma/handlers/main.yml new file mode 100644 index 0000000..28fcb0a --- /dev/null +++ b/ansible/roles/uptime_kuma/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart uptime-kuma + shell: + chdir: /opt/uptime-kuma + cmd: "{{ docker_update_command }}" diff --git a/ansible/roles/uptime_kuma/tasks/main.yml b/ansible/roles/uptime_kuma/tasks/main.yml new file mode 100644 index 0000000..a2b460a --- /dev/null +++ b/ansible/roles/uptime_kuma/tasks/main.yml @@ -0,0 +1,17 @@ +- name: Create install directory + file: + path: /opt/uptime-kuma + state: directory + owner: "{{ docker_user.name }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + +- name: Install compose file + template: + src: files/docker-compose.yml + dest: /opt/uptime-kuma/docker-compose.yml + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + validate: docker-compose -f %s config + notify: restart uptime-kuma + become: true diff --git a/terraform/jakehoward.tech.tf b/terraform/jakehoward.tech.tf index afed4c0..f2196d0 100644 --- a/terraform/jakehoward.tech.tf +++ b/terraform/jakehoward.tech.tf @@ -261,6 +261,14 @@ resource "cloudflare_record" "jakehowardtech_slides" { ttl = 1 } +resource "cloudflare_record" "jakehowardtech_uptime" { + zone_id = cloudflare_zone.jakehowardtech.id + name = "uptime" + value = cloudflare_record.sys_domain_pve.hostname + type = "CNAME" + ttl = 1 +} + resource "cloudflare_record" "jakehowardtech_caa" { zone_id = cloudflare_zone.jakehowardtech.id name = "@"