Files
gitlab-mirror/roles/uptime_kuma/tasks/configure.yml
2026-03-14 20:53:27 +04:00

67 lines
2.6 KiB
YAML

---
- name: "Wait for uptime-kuma to start"
ansible.builtin.wait_for:
port: "{{ uptime_kuma_port }}"
timeout: 30
- name: "Set up uptime-kuma credentials"
lucasheld.uptime_kuma.setup:
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
api_username: "{{ uptime_kuma_api_username }}"
api_password: "{{ uptime_kuma_api_password }}"
- name: "Login with credentials once and register the result"
register: uptime_kuma_result
lucasheld.uptime_kuma.login:
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
api_username: "{{ uptime_kuma_api_username }}"
api_password: "{{ uptime_kuma_api_password }}"
- name: "Extract the token from the result and set it as fact"
ansible.builtin.set_fact:
uptime_kuma_api_token: "{{ uptime_kuma_result.token }}"
- name: "Configure Telegram notification method"
when:
- uptime_kuma_tg_bot_token is defined
- uptime_kuma_tg_chat_id is defined
lucasheld.uptime_kuma.notification:
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
api_token: "{{ uptime_kuma_api_token }}"
type: telegram
name: "{{ uptime_kuma_tg_notif_name | default('Telegram alerts') }}"
isDefault: "{{ uptime_kuma_tg_notif_is_default | default(true) }}"
applyExisting: "{{ uptime_kuma_tg_notif_apply_existing | default(true) }}"
telegramBotToken: "{{ uptime_kuma_tg_bot_token }}"
telegramChatID: "{{ uptime_kuma_tg_chat_id }}"
state: "present"
- name: "Create monitor groups"
when: uptime_kuma_monitor_groups is defined
loop: "{{ uptime_kuma_monitor_groups }}"
lucasheld.uptime_kuma.monitor:
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
api_token: "{{ uptime_kuma_api_token }}"
type: "group"
name: "{{ item }}"
- name: "Create monitors"
loop: "{{ uptime_kuma_monitors }}"
lucasheld.uptime_kuma.monitor:
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
api_token: "{{ uptime_kuma_api_token }}"
type: "{{ item.type }}"
name: "{{ item.name }}"
upsideDown: "{{ item.upside_down | default(false) }}"
url: "{{ item.url | default(omit) }}"
hostname: "{{ item.hostname | default(omit) }}"
port: "{{ item.port | default(omit) }}"
interval: "{{ item.interval | default(60) }}"
description: "{{ item.description | default(omit) }}"
parent_name: "{{ item.parent_name | default(omit) }}"
notification_names: "{{ item.notification_names | default(uptime_kuma_default_notification_names) }}"
state: "{{ uptime_kuma_tg_notif_state | default('present') }}"
ignoreTls: "{{ item.ignore_tls | default(false) }}"
jsonPath: "{{ item.query | default(omit) }}"
expectedValue: "{{ item.expected_value | default(omit) }}"