fix ansible-lint errors
This commit is contained in:
@@ -15,12 +15,12 @@ None
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
- `kuma_img_version`: Kuma container version
|
||||
- `kuma_project_dir`: where to put Docker Compose file and keep Kuma's data
|
||||
- `kuma_port`: listening port for Kuma API and web interface
|
||||
- `kuma_api_version`: version of the Python API
|
||||
- `kuma_limit_cpus`: CPU cores limit for Kuma
|
||||
- `kuma_limit_ram`: RAM limit for Kuma
|
||||
- `uptime_kuma_img_version`: Kuma container version
|
||||
- `uptime_kuma_project_dir`: where to put Docker Compose file and keep Kuma's data
|
||||
- `uptime_kuma_port`: listening port for Kuma API and web interface
|
||||
- `uptime_kuma_api_version`: version of the Python API
|
||||
- `uptime_kuma_limit_cpus`: CPU cores limit for Kuma
|
||||
- `uptime_kuma_limit_ram`: RAM limit for Kuma
|
||||
- `kuma_tg_notif_name`: Name for Telegram notification method
|
||||
- `kuma_tg_notif_is_default`: make this notification method default (default: `true`)
|
||||
- `kuma_tg_notif_apply_existing`: connect all existing monitors to this notification method (default: `true`)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
kuma_img_version: "1.23.16-alpine"
|
||||
kuma_project_dir: "/uptime-kuma"
|
||||
kuma_port: 3001
|
||||
kuma_api_version: "1.2.0"
|
||||
kuma_limit_cpus: 2
|
||||
kuma_limit_ram: "2G"
|
||||
kuma_default_notification_names: []
|
||||
uptime_kuma_img_version: "1.23.16-alpine"
|
||||
uptime_kuma_project_dir: "/uptime-kuma"
|
||||
uptime_kuma_port: 3001
|
||||
uptime_kuma_api_version: "1.2.0"
|
||||
uptime_kuma_limit_cpus: 2
|
||||
uptime_kuma_limit_ram: "2G"
|
||||
uptime_kuma_default_notification_names: []
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
test_admin_username: admin
|
||||
test_admin_password: SDjj3$k4g9dhsjd__1dj
|
||||
roles:
|
||||
- genlab.docker_ubuntu
|
||||
- genlab.common.docker_ubuntu
|
||||
tasks:
|
||||
- name: "Test the role"
|
||||
tags: [role]
|
||||
ansible.builtin.include_role:
|
||||
name: "genlab.uptime_kuma"
|
||||
name: "genlab.common.uptime_kuma"
|
||||
vars:
|
||||
kuma_api_username: "{{ test_admin_username }}"
|
||||
kuma_api_password: "{{ test_admin_password }}"
|
||||
kuma_tg_bot_token: 8161628020:AAF9doUFKSwdK4NZ8z58zVpqq0H1EdrKnI1
|
||||
kuma_tg_chat_id: -4877676122
|
||||
kuma_default_notification_names: ["Telegram alerts"]
|
||||
uptime_kuma_default_notification_names: ["Telegram alerts"]
|
||||
kuma_monitors:
|
||||
- name: "push-test"
|
||||
type: push
|
||||
|
||||
@@ -18,26 +18,26 @@
|
||||
|
||||
tasks:
|
||||
- name: "Verify uptime-kuma responds to HTTP requests"
|
||||
register: this
|
||||
until: this is ansible.builtin.success
|
||||
register: uptime_kuma_this
|
||||
until: uptime_kuma_this is ansible.builtin.success
|
||||
retries: 3
|
||||
delay: 3
|
||||
ansible.builtin.uri:
|
||||
url: "http://127.0.0.1:{{ kuma_port }}"
|
||||
url: "http://127.0.0.1:{{ uptime_kuma_port }}"
|
||||
method: GET
|
||||
status_code: 200
|
||||
|
||||
- name: "Get monitor information"
|
||||
register: monitors
|
||||
register: uptime_kuma_monitors
|
||||
lucasheld.uptime_kuma.monitor_info:
|
||||
api_url: http://127.0.0.1:3001
|
||||
api_username: "{{ test_admin_username }}"
|
||||
api_password: "{{ test_admin_password }}"
|
||||
|
||||
- name: "Get test monitor information"
|
||||
failed_when: monitor_info is not defined
|
||||
failed_when: uptime_kuma_monitor_info is not defined
|
||||
ansible.builtin.set_fact:
|
||||
monitor_info: "{{ monitors.monitors | selectattr('name', 'equalto', 'push-test') | list | first }}"
|
||||
uptime_kuma_monitor_info: "{{ uptime_kuma_monitors.monitors | selectattr('name', 'equalto', 'push-test') | list | first }}"
|
||||
|
||||
- name: "Check test monitor configuration"
|
||||
loop:
|
||||
@@ -46,6 +46,6 @@
|
||||
- {key: "description", value: "Test push monitor"}
|
||||
- {key: notificationIDList, value: [1]} # names are not stored, only integer IDs
|
||||
ansible.builtin.assert:
|
||||
that: "monitor_info[item.key] == item.value"
|
||||
that: "uptime_kuma_monitor_info[item.key] == item.value"
|
||||
success_msg: "Test monitor has correctly configured {{ item.key }}: {{ item.value }}"
|
||||
fail_msg: "Incorrect test monitor configuration for {{ item.key }}: expected {{ item.value }}, got: {{ monitor_info[item.key] }}"
|
||||
fail_msg: "Incorrect test monitor configuration for {{ item.key }}: expected {{ item.value }}, got: {{ uptime_kuma_monitor_info[item.key] }}"
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
---
|
||||
- name: "Wait for uptime-kuma to start"
|
||||
ansible.builtin.wait_for:
|
||||
port: "{{ kuma_port }}"
|
||||
port: "{{ uptime_kuma_port }}"
|
||||
timeout: 30
|
||||
|
||||
- name: "Set up uptime-kuma credentials"
|
||||
lucasheld.uptime_kuma.setup:
|
||||
api_url: http://127.0.0.1:{{ kuma_port }}
|
||||
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
|
||||
api_username: "{{ kuma_api_username }}"
|
||||
api_password: "{{ kuma_api_password }}"
|
||||
|
||||
- name: "Login with credentials once and register the result"
|
||||
register: result
|
||||
register: uptime_kuma_result
|
||||
lucasheld.uptime_kuma.login:
|
||||
api_url: http://127.0.0.1:{{ kuma_port }}
|
||||
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
|
||||
api_username: "{{ kuma_api_username }}"
|
||||
api_password: "{{ kuma_api_password }}"
|
||||
|
||||
- name: "Extract the token from the result and set it as fact"
|
||||
ansible.builtin.set_fact:
|
||||
kuma_api_token: "{{ result.token }}"
|
||||
uptime_kuma_api_token: "{{ uptime_kuma_result.token }}"
|
||||
|
||||
- name: "Configure Telegram notification method"
|
||||
when:
|
||||
- kuma_tg_bot_token is defined
|
||||
- kuma_tg_chat_id is defined
|
||||
lucasheld.uptime_kuma.notification:
|
||||
api_url: http://127.0.0.1:{{ kuma_port }}
|
||||
api_token: "{{ kuma_api_token }}"
|
||||
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
|
||||
api_token: "{{ uptime_kuma_api_token }}"
|
||||
type: telegram
|
||||
name: "{{ kuma_tg_notif_name | default('Telegram alerts') }}"
|
||||
isDefault: "{{ kuma_tg_notif_is_default | default(true) }}"
|
||||
@@ -40,16 +40,16 @@
|
||||
when: kuma_monitor_groups is defined
|
||||
loop: "{{ kuma_monitor_groups }}"
|
||||
lucasheld.uptime_kuma.monitor:
|
||||
api_url: http://127.0.0.1:{{ kuma_port }}
|
||||
api_token: "{{ kuma_api_token }}"
|
||||
api_url: http://127.0.0.1:{{ uptime_kuma_port }}
|
||||
api_token: "{{ uptime_kuma_api_token }}"
|
||||
type: "group"
|
||||
name: "{{ item }}"
|
||||
|
||||
- name: "Create monitors"
|
||||
loop: "{{ kuma_monitors }}"
|
||||
lucasheld.uptime_kuma.monitor:
|
||||
api_url: http://127.0.0.1:{{ kuma_port }}
|
||||
api_token: "{{ kuma_api_token }}"
|
||||
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) }}"
|
||||
@@ -59,7 +59,7 @@
|
||||
interval: "{{ item.interval | default(60) }}"
|
||||
description: "{{ item.description | default(omit) }}"
|
||||
parent_name: "{{ item.parent_name | default(omit) }}"
|
||||
notification_names: "{{ item.notification_names | default(kuma_default_notification_names) }}"
|
||||
notification_names: "{{ item.notification_names | default(uptime_kuma_default_notification_names) }}"
|
||||
state: "{{ kuma_tg_notif_state | default('present') }}"
|
||||
ignoreTls: "{{ item.ignore_tls | default(false) }}"
|
||||
jsonPath: "{{ item.query | default(omit) }}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: "Ensure project directory exists"
|
||||
ansible.builtin.file:
|
||||
path: "{{ kuma_project_dir }}"
|
||||
path: "{{ uptime_kuma_project_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
@@ -10,7 +10,7 @@
|
||||
- name: "Push the Compose file"
|
||||
ansible.builtin.template:
|
||||
src: "docker-compose.yml.j2"
|
||||
dest: "{{ kuma_project_dir }}/docker-compose.yml"
|
||||
dest: "{{ uptime_kuma_project_dir }}/docker-compose.yml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0660"
|
||||
@@ -18,10 +18,10 @@
|
||||
- name: "Deploy uptime-kuma via Docker Compose"
|
||||
community.docker.docker_compose_v2:
|
||||
state: present
|
||||
project_src: "{{ kuma_project_dir }}"
|
||||
project_src: "{{ uptime_kuma_project_dir }}"
|
||||
|
||||
- name: "Install Python dependencies"
|
||||
ansible.builtin.pip:
|
||||
name: "uptime-kuma-api"
|
||||
version: "{{ kuma_api_version }}"
|
||||
version: "{{ uptime_kuma_api_version }}"
|
||||
break_system_packages: true
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
---
|
||||
services:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:{{ kuma_img_version }}
|
||||
image: louislam/uptime-kuma:{{ uptime_kuma_img_version }}
|
||||
container_name: uptime-kuma
|
||||
volumes:
|
||||
- {{ kuma_project_dir }}/data:/app/data
|
||||
- {{ uptime_kuma_project_dir }}/data:/app/data
|
||||
restart: unless-stopped
|
||||
cap_drop:
|
||||
- ALL
|
||||
@@ -30,8 +30,8 @@ services:
|
||||
replicas: 1
|
||||
resources:
|
||||
limits:
|
||||
cpus: {{ kuma_limit_cpus }}
|
||||
memory: {{ kuma_limit_ram }}
|
||||
cpus: {{ uptime_kuma_limit_cpus }}
|
||||
memory: {{ uptime_kuma_limit_ram }}
|
||||
|
||||
volumes:
|
||||
uptime-kuma-data:
|
||||
|
||||
Reference in New Issue
Block a user