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