From f3bc72d2baa08a4e937ecccbc7c8b6e75502cf6c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 31 Jul 2021 16:30:33 +0100 Subject: [PATCH] Provision uptime-kuma --- ansible/main.yml | 1 + .../roles/uptime_kuma/files/docker-compose.yml | 14 ++++++++++++++ ansible/roles/uptime_kuma/handlers/main.yml | 4 ++++ ansible/roles/uptime_kuma/tasks/main.yml | 17 +++++++++++++++++ terraform/jakehoward.tech.tf | 8 ++++++++ 5 files changed, 44 insertions(+) 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/main.yml b/ansible/main.yml index 729dacd..867e8da 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -88,6 +88,7 @@ - plausible - pages - restic + - uptime_kuma - hosts: jellyfin roles: 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..ba4992c --- /dev/null +++ b/ansible/roles/uptime_kuma/files/docker-compose.yml @@ -0,0 +1,14 @@ +version: "2.3" + +services: + uptime-kuma: + image: louislam/uptime-kuma:1 + restart: unless-stopped + user: "{{ docker_user.id }}:{{ docker_user.id }}" + volumes: + - ./data:/app/data + labels: + - traefik.enable=true + - traefik.http.routers.uptime-kuma.rule=Host(`uptime.jakehoward.tech`) + - traefik.http.routers.uptime-kuma.tls.certresolver=le + - traefik.http.routers.uptime-kuma.middlewares=compress@file 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 a72a7f9..e4a200f 100644 --- a/terraform/jakehoward.tech.tf +++ b/terraform/jakehoward.tech.tf @@ -147,3 +147,11 @@ resource "cloudflare_record" "jakehowardtech_vaultwarden" { type = "A" ttl = 1 } + +resource "cloudflare_record" "jakehowardtech_uptime" { + zone_id = cloudflare_zone.jakehowardtech.id + name = "uptime" + value = vultr_instance.walker.main_ip + type = "A" + ttl = 1 +}