2025-07-01 16:14:44 +02:00
|
|
|
- name: Deploy Uptime Kuma with Docker Compose and configure Caddy reverse proxy
|
|
|
|
|
hosts: vipy
|
|
|
|
|
become: yes
|
2025-07-01 17:02:28 +02:00
|
|
|
vars_files:
|
2025-07-02 17:17:56 +02:00
|
|
|
- ../../infra_vars.yml
|
|
|
|
|
- ./uptime_kuma_vars.yml
|
2025-07-01 16:14:44 +02:00
|
|
|
vars:
|
2025-07-02 17:17:56 +02:00
|
|
|
uptime_kuma_domain: "{{ uptime_kuma_subdomain }}.{{ root_domain }}"
|
2025-07-01 16:14:44 +02:00
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
- name: Create uptime kuma directory
|
|
|
|
|
file:
|
|
|
|
|
path: "{{ uptime_kuma_dir }}"
|
|
|
|
|
state: directory
|
2025-07-01 17:02:28 +02:00
|
|
|
owner: "{{ ansible_user }}"
|
|
|
|
|
group: "{{ ansible_user }}"
|
2025-07-01 16:14:44 +02:00
|
|
|
mode: '0755'
|
|
|
|
|
|
|
|
|
|
- name: Create docker-compose.yml for uptime kuma
|
|
|
|
|
copy:
|
|
|
|
|
dest: "{{ uptime_kuma_dir }}/docker-compose.yml"
|
|
|
|
|
content: |
|
|
|
|
|
version: "3"
|
|
|
|
|
services:
|
|
|
|
|
uptime-kuma:
|
|
|
|
|
image: louislam/uptime-kuma:latest
|
|
|
|
|
container_name: uptime-kuma
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
ports:
|
|
|
|
|
- "{{ uptime_kuma_port }}:3001"
|
|
|
|
|
volumes:
|
|
|
|
|
- ./data:/app/data
|
|
|
|
|
|
|
|
|
|
- name: Deploy uptime kuma container with docker compose
|
2025-07-01 17:02:28 +02:00
|
|
|
command: docker compose up -d
|
2025-07-01 16:14:44 +02:00
|
|
|
args:
|
|
|
|
|
chdir: "{{ uptime_kuma_dir }}"
|
|
|
|
|
|
2025-07-01 17:02:28 +02:00
|
|
|
- name: Ensure Caddy sites-enabled directory exists
|
|
|
|
|
file:
|
|
|
|
|
path: /etc/caddy/sites-enabled
|
|
|
|
|
state: directory
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0755'
|
|
|
|
|
|
|
|
|
|
- name: Ensure Caddyfile includes import directive for sites-enabled
|
|
|
|
|
lineinfile:
|
|
|
|
|
path: /etc/caddy/Caddyfile
|
|
|
|
|
line: 'import sites-enabled/*'
|
|
|
|
|
insertafter: EOF
|
|
|
|
|
state: present
|
|
|
|
|
backup: yes
|
|
|
|
|
|
2025-07-01 16:14:44 +02:00
|
|
|
- name: Create Caddy reverse proxy configuration for uptime kuma
|
|
|
|
|
copy:
|
|
|
|
|
dest: "{{ caddy_sites_dir }}/uptime-kuma.conf"
|
|
|
|
|
content: |
|
|
|
|
|
{{ uptime_kuma_domain }} {
|
|
|
|
|
reverse_proxy localhost:{{ uptime_kuma_port }}
|
|
|
|
|
}
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0644'
|
|
|
|
|
|
|
|
|
|
- name: Reload Caddy to apply new config
|
|
|
|
|
command: systemctl reload caddy
|