lucasheld / ansible-uptime-kuma Goto Github PK
View Code? Open in Web Editor NEWAnsible collection of modules to configure Uptime Kuma
License: GNU General Public License v3.0
Ansible collection of modules to configure Uptime Kuma
License: GNU General Public License v3.0
I'm trying to add multiple json-query monitors and I get the following error:
msg: 'value of type must be one of: http, port, ping, keyword, grpc-keyword, dns, docker, push, steam, gamedig, mqtt, sqlserver, postgres, mysql, mongodb, radius, redis, got: json-query'
Looks like it is documented but not implemented?
To set the 'disableAuth' to true the password needs to be present.
In the python api this is done by adding the password param to the 'set_settings' call. See uptime-api
It looks like the password value is not part of set_settings call.
The way I tried to disableAuth in ansible:
- name: Disable auth
lucasheld.uptime_kuma.settings:
api_url: "{{ api_url }}"
api_username: "{{ api_username }}"
api_password: "{{ api_password }}"
disableAuth: true
Following error occured:
The full traceback is:
File "/tmp/ansible_lucasheld.uptime_kuma.settings_payload_fjkg8r62/ansible_lucasheld.uptime_kuma.settings_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/settings.py", line 161, in main
File "/tmp/ansible_lucasheld.uptime_kuma.settings_payload_fjkg8r62/ansible_lucasheld.uptime_kuma.settings_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/settings.py", line 108, in run
File "/usr/local/lib/python3.10/dist-packages/uptime_kuma_api/api.py", line 2819, in set_settings
return self._call('setSettings', (data, password))
File "/usr/local/lib/python3.10/dist-packages/uptime_kuma_api/api.py", line 550, in _call
raise UptimeKumaException(r.get("msg"))
fatal: [localhost]: FAILED! => changed=false
invocation:
module_args:
api_headers: null
api_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
api_ssl_verify: true
api_timeout: 10.0
api_token: null
api_url: http://localhost:3001
api_username: admin
api_wait_events: 0.2
checkBeta: null
checkUpdate: null
chromeExecutable: null
disableAuth: true
dnsCache: null
entryPage: null
keepDataPeriodDays: null
nscd: null
password: null
primaryBaseURL: null
searchEngineIndex: null
serverTimezone: Europe/Berlin
steamAPIKey: null
tlsExpiryNotifyDays: null
trustProxy: null
msg: |-
Traceback (most recent call last):
File "/tmp/ansible_lucasheld.uptime_kuma.settings_payload_fjkg8r62/ansible_lucasheld.uptime_kuma.settings_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/settings.py", line 161, in main
File "/tmp/ansible_lucasheld.uptime_kuma.settings_payload_fjkg8r62/ansible_lucasheld.uptime_kuma.settings_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/settings.py", line 108, in run
File "/usr/local/lib/python3.10/dist-packages/uptime_kuma_api/api.py", line 2819, in set_settings
return self._call('setSettings', (data, password))
File "/usr/local/lib/python3.10/dist-packages/uptime_kuma_api/api.py", line 550, in _call
raise UptimeKumaException(r.get("msg"))
uptime_kuma_api.exceptions.UptimeKumaException: Wrong data type?
Hey,
we are trying to manage our uptime kuma with this Ansible playbook and fail with the parameter headers. We need to pass custom headers on a monitoring request and are trying to do this using headers and a JSON. But with the JSON, double quotes are converted to single quotes either by this module or Ansible+Jinja. So do you have a working example of setting up monitoring with custom headers?
headers: '{"customer-header-1": "value-of-header-1", "customer-header-2": "value-of-header-2"}'
... becomes {'customer-header-1':'value-of-header-1','customer-header-2':'value-of-header-2'} in uptime kuma and then ends in a 401 error at uptime kuma, because it is not a valid json for uptime kuma.
Thx for your help :-)
Hi,
we try to create a monitor tag
- name: Create first http monitor tag
lucasheld.uptime_kuma.monitor_tag:
api_url: "http://{{ kuma_host }}"
api_token: "{{ api_token }}"
monitor_name: "api Service"
tag_name: "tag1"
value: "namespace: foo"
state: present
however it outputs
TASK [kuma : Create first http monitor tag] ********************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_tag_payload_x4o8bo5_/ansible_lucasheld.uptime_kuma.monitor_tag_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_tag.py\", line 155, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_tag_payload_x4o8bo5_/ansible_lucasheld.uptime_kuma.monitor_tag_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_tag.py\", line 111, in run\nTypeError: 'NoneType' object is not subscriptable\n"}
cheers
If one uses the latest docker-compose.yml
(which specifies the docker image tag 1
= latest
= 1.22.0-debian
), the creation of a status_page
results in a ValueError
.
Used docker-compose.yml
file:
# Simple docker-compose.yml
# You can change your port or volume location
version: '3.3'
services:
uptime-kuma:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
volumes:
- ./uptime-kuma-data:/app/data
ports:
- 3001:3001 # <Host Port>:<Container Port>
restart: always
Example Ansible role to trigger the bug:
#
# Configuration and setup
#
- name: Specify the initial username and password
lucasheld.uptime_kuma.setup:
api_url: http://127.0.0.1:3001
api_username: root
api_password: 123abc
- name: Login with credentials once and register the result
lucasheld.uptime_kuma.login:
api_url: http://127.0.0.1:3001
api_username: root
api_password: 123abc
register: result
- name: Extract the token from the result and set it as fact
set_fact:
api_token: "{{ result.token }}"
- name: Configure base URL and trust proxy parameters
lucasheld.uptime_kuma.settings:
api_url: http://127.0.0.1:3001
api_token: "{{ api_token }}"
primaryBaseURL: https://testurl.tld
trustProxy: true
#
# Monitors
#
- name: Create monitor for Google website
lucasheld.uptime_kuma.monitor:
api_url: http://127.0.0.1:3001
api_token: "{{ api_token }}"
name: Google website
type: http
url: https://google.com
state: present
#
# Status pages
#
- name: Add Google status page
lucasheld.uptime_kuma.status_page:
api_url: http://127.0.0.1:3001
api_token: "{{ api_token }}"
slug: google
title: google
state: present
publicGroupList:
- name: Services
weight: 1
monitorList:
- name: Google website
Output:
[...]
TASK [uptime-kuma : Add Google status page] *************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_kih1c0mh/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py\", line 278, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_kih1c0mh/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py\", line 199, in run\n File \"/home/mkratz/.local/lib/python3.10/site-packages/uptime_kuma_api/api.py\", line 1926, in save_status_page\n data = _build_status_page_data(**status_page)\n File \"/home/mkratz/.local/lib/python3.10/site-packages/uptime_kuma_api/api.py\", line 210, in _build_status_page_data\n raise ValueError\nValueError\n"}
However, if I change the uptime kuma version (i.e., the docker image tag in the docker-compose.yml
file) to louislam/uptime-kuma:1.21.3
, everything works as expected.
I did see that the latest official supported uptime kuma version of this project is 1.21.3
, but nevertheless, I wanted to file this bug. Maybe it is helpful for future development etc.
Adding monitors with ansible works but when trying to add a statuspage it errors with SQLITE_CONSTRAINT: UNIQUE constraint failed: status_page.slug
Im using version 1.2.0 of ansible-uptime-kuma and 1.23.11 (current latest) of uptime kuma.
I also tested hosting a container of the 1.23.1 version, where I could add statuspages without a problem. So I'd assume the issue stems from a version conflict.
The issue is not caused by the version of uptime kuma. The page addition also fails on 1.23.1 if I open the API url with https, but works over http. I originally only tested on 1.23.1 with http and assumed that was the issue.
The main.yml contains the following:
- name: PAGE | Add status page with monitor
lucasheld.uptime_kuma.status_page:
api_url: https://mypage:443
api_token: "{{ api_token }}"
api_ssl_verify: no
slug: "testpage"
title: "testtitle"
state: present
publicGroupList:
- name: TestGroup
weight: 1
monitorList:
- name: TestMonitor1
- name: TestMonitor2
running the playbok with -vvv returns the following:
TASK [PAGE | Add status page with monitor] **************************************************************************************************************************************************************************************
task path: /home/gutz430/git/itservices/ansible/uptime/playbooks/main.yml:185
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: gutz430
<127.0.0.1> EXEC /bin/sh -c 'echo ~gutz430 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/gutz430/.ansible/tmp `"&& mkdir "` echo /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123 `" && echo ansible-tmp-1708509669.2697048-14738-110512085971123="` echo /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123 `" ) && sleep 0'
Using module file /home/gutz430/.ansible/collections/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py
<127.0.0.1> PUT /home/gutz430/.ansible/tmp/ansible-local-13829c31gsafc/tmpez6417gx TO /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123/AnsiballZ_status_page.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123/ /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123/AnsiballZ_status_page.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123/AnsiballZ_status_page.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/gutz430/.ansible/tmp/ansible-tmp-1708509669.2697048-14738-110512085971123/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_g0u54i77/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py", line 284, in main
File "/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_g0u54i77/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py", line 203, in run
File "/home/gutz430/.local/lib/python3.9/site-packages/uptime_kuma_api/api.py", line 2044, in add_status_page
return self._call('addStatusPage', (title, slug))
File "/home/gutz430/.local/lib/python3.9/site-packages/uptime_kuma_api/api.py", line 550, in _call
raise UptimeKumaException(r.get("msg"))
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"api_headers": null,
"api_password": null,
"api_ssl_verify": false,
"api_timeout": 10.0,
"api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"api_url": "https://mypage:443",
"api_username": null,
"api_wait_events": 0.2,
"customCSS": null,
"description": null,
"domainNameList": null,
"footerText": null,
"googleAnalyticsId": null,
"icon": null,
"incident": null,
"publicGroupList": [
{
"monitorList": [
{
"id": 21
},
{
"id": 22
}
],
"name": "TestGroup",
"weight": 1
}
],
"published": null,
"showPoweredBy": null,
"showTags": null,
"slug": "testpage",
"state": "present",
"theme": null,
"title": "testtitle"
}
},
"msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_g0u54i77/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py\", line 284, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.status_page_payload_g0u54i77/ansible_lucasheld.uptime_kuma.status_page_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/status_page.py\", line 203, in run\n File \"/home/gutz430/.local/lib/python3.9/site-packages/uptime_kuma_api/api.py\", line 2044, in add_status_page\n return self._call('addStatusPage', (title, slug))\n File \"/home/gutz430/.local/lib/python3.9/site-packages/uptime_kuma_api/api.py\", line 550, in _call\n raise UptimeKumaException(r.get(\"msg\"))\nuptime_kuma_api.exceptions.UptimeKumaException: insert into `status_page` (`icon`, `slug`, `theme`, `title`) values ('', 'testpage', 'auto', 'Ansuble testtitle') - SQLITE_CONSTRAINT: UNIQUE constraint failed: status_page.slug\n"
}
PLAY RECAP **********************************************************************************************************************************************************************************************************************
localhost : ok=18 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
If a monitor includes notifications, then that task always returns changed
when re-run, even if the nothing in the monitor configuration has changed (i.e., these tasks are non-idempotent).
This issue is somewhat related to a previous issue I filed on the uptime-kuma-api in that the need to translate the simple array of integer notification IDs into the dict of {<id>: True, etc...}
looks to be the cause. I haven't looked into the Uptime Kuma source to try to understand why it needs that format, but maybe we can get that changed to avoid this translation entirely :)
Anyways, the issue is that the object_changed function in module_utils/common.py
detects a "change" in notifications because it is comparing the object that looks like {'14': True, '15': True}
returned from the existing monitor with the array of integers ([14, 15]
) from the task's attributes, which obviously don't match, even though they represent the same notifications already being configured as the playbook is requested be configured.
I'll share my current workaround as a PR, but I am not sure it's the best way to solve this problem.
Hey, thanks for this collection and the Python library, both have been super useful for me, really appreciate the work.
I've encountered a bug with the maintenance
module. The following task causes the error noted in the title:
- name: Set maintenance schedules
lucasheld.uptime_kuma.maintenance:
title: Plex Sync
description: Plex server synchronisation
strategy: recurring-weekday
intervalDay: 1
weekdays: [2, 3, 4, 5, 6, 7, 0]
timeRange:
- hours: 7
minutes: 0
- hours: 7
minutes: 30
monitors:
- name: Plex Media Server
- name: Backup Plex Media Server
tags: maintenance
This seems to be caused by attempting to sort a list of dicts here: maintenance.py#L252
Hey there - thanks for this integration! We currently are managing an instance of uptime kuma as code through this.
I can't seem to make the SMTP work - is it implemented? If so, would you mind providing with an example? - Is weird because all the other notification types work very well.
i've problem when i want to add new status page with status
and status page info
module, there is error with the sqlite, here's the error log
uptime_kuma_api.exceptions.UptimeKumaException: insert into \`status_page\` (\`icon\`, \`slug\`, \`theme\`, \`title\`) values ('', 'xxx-monitoring', 'light', 'xxx-monitoring') - SQLITE_CONSTRAINT: UNIQUE constraint failed: status_page.slug
Hello,
we need to parse pushToken and url to use it in our scripts to push messages to a push-monitor.
lucasheld.uptime_kuma.monitor:
api_url: "http://{{ kuma_host }}"
api_token: "{{ api_token }}"
name: BackupScript
type: push
interval: 60
maxretries: 0
state: present
- name: get push monitor
lucasheld.uptime_kuma.monitor_info:
api_url: "http://{{ kuma_host }}"
api_token: "{{ api_token }}"
name: BackupScript
register: push_monitor_result
- name: debug push_monitor_pushToken
debug: msg="{{ push_monitor_result.monitors }}"
however the above outputs Null for these return values
ok: [localhost] => {
"msg": [
{
"accepted_statuscodes": [
"200-299"
],
"active": true,
"authDomain": null,
"authMethod": "",
"authWorkstation": null,
"basic_auth_pass": null,
"basic_auth_user": null,
"body": null,
"databaseConnectionString": null,
"databaseQuery": null,
"dns_last_result": null,
"dns_resolve_server": "1.1.1.1",
"dns_resolve_type": "A",
"docker_container": null,
"docker_host": null,
"expiryNotification": false,
"headers": null,
"hostname": null,
"id": 2,
"ignoreTls": false,
"interval": 60,
"keyword": null,
"maxredirects": 10,
"maxretries": 0,
"method": "GET",
"mqttPassword": null,
"mqttSuccessMessage": null,
"mqttTopic": null,
"mqttUsername": null,
"name": "BackupScript",
"notificationIDList": [],
"port": 53,
"proxyId": null,
"pushToken": null,
"radiusCalledStationId": null,
"radiusCallingStationId": null,
"radiusPassword": null,
"radiusSecret": null,
"radiusUsername": null,
"resendInterval": 0,
"retryInterval": 60,
"tags": [],
"type": "push",
"upsideDown": false,
"url": null,
"weight": 2000
}
]
}```
I am trying to create a tag like this:
- name: Add Development tag
lucasheld.uptime_kuma.tag:
api_url: http://127.0.0.1:3001
api_token: "{{ api_token }}"
name: Development
color: "#0000ff"
state: present
but it fails with this error:
FAILED! => {"changed": false, "msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.tag_payload_esq43o_3/ansible_lucasheld.uptime_kuma.tag_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/tag.py\", line 129, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.tag_payload_esq43o_3/ansible_lucasheld.uptime_kuma.tag_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/tag.py\", line 89, in run\nTypeError: add_tag() takes 1 positional argument but 3 were given\n"}
it's not working.
please help me.
An error occurs when I enter the command below.
ansible-galaxy collection install git+https://github.com/lucasheld/ansible-uptime-kuma.git
ERROR! Invalid collection name 'git+https', name must be in the format .. Please make sure namespace and collection name contains characters from [a-zA-Z0-9_] only.
When adding tags to a monitor, 'value' is optional in the Web GUI but through Ansible, 'value' is required. This causes our tags to be inconsistent because when adding a tag through Ansible it adds 'null' to the tag.
Hi @lucasheld
I'm trying to install the ansible role as stated and I get the following errors:
$ ansible --version
ansible 2.9.6
$ ansible-galaxy --version
ansible-galaxy 2.9.6
$ ansible-galaxy collection install git+https://github.com/lucasheld/ansible-uptime-kuma.git
Process install dependency map
ERROR! Invalid collection name 'git+https', name must be in the format .. Please make sure namespace and collection name contains characters from [a-zA-Z0-9_] only.
$ ansible-galaxy role install -fgr requirements.yml
[WARNING]: - ansible-uptime-kuma was NOT installed successfully: this role does not appear to have a meta/main.yml file.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
Can you please help?
subj
It would be great if the Json Query monitor introduced in 1.23.0 could be supported. No rush of course, thanks for this great project โค๏ธ
Dear @lucasheld ,
at the moment I work on a ansible role that installs uptime-kuma with docker-compose. After the installation the role configures the uptime-kuma instance with your amazing modules.
I want to add the role to your collection.
Do you agree?
Hey there,
I'm not able to use the Modules :( Following is the Error:
Using module file /Users/stephan.schaffner/.ansible/collections/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py
Pipelining is enabled.
<10.24.1.7> ESTABLISH SSH CONNECTION FOR USER: stephan
<10.24.1.7> SSH: EXEC ssh -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=10m -o ControlPath=/tmp/ansible_ssh_%r@%h:%p -o StrictHostKeyChecking=no -o Port=42022 -o 'IdentityFile="รคou"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="stephan"' -o ConnectTimeout=5 10.24.1.7 '/bin/sh -c '"'"'sudo -H -S -p "[sudo via ansible, key=q] password:" -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-q ; /usr/bin/python3'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<10.24.1.7> (1, b'', b'Traceback (most recent call last):\n File "<stdin>", line 107, in <module>\n File "<stdin>", line 99, in _ansiballz_main\n File "<stdin>", line 47, in invoke_module\n File "<frozen runpy>", line 226, in run_module\n File "<frozen runpy>", line 98, in _run_module_code\n File "<frozen runpy>", line 88, in _run_code\n File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 589, in <module>\n File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 449, in main\nNameError: name \'MonitorType\' is not defined\n')
<10.24.1.7> Failed to connect to the host via ssh: Traceback (most recent call last):
File "<stdin>", line 107, in <module>
File "<stdin>", line 99, in _ansiballz_main
File "<stdin>", line 47, in invoke_module
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 589, in <module>
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 449, in main
NameError: name 'MonitorType' is not defined
The full traceback is:
Traceback (most recent call last):
File "<stdin>", line 107, in <module>
File "<stdin>", line 99, in _ansiballz_main
File "<stdin>", line 47, in invoke_module
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 589, in <module>
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 449, in main
NameError: name 'MonitorType' is not defined
fatal: [netbox.vv.de]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "<stdin>", line 107, in <module>
File "<stdin>", line 99, in _ansiballz_main
File "<stdin>", line 47, in invoke_module
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 589, in <module>
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_x99wq4wu/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 449, in main
NameError: name 'MonitorType' is not defined
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
Hi,
we explored the following issue
- name: Login with credentials once and register the token
lucasheld.uptime_kuma.login:
api_url: "http://{{ kuma_host }}"
api_username: "{{ gui_user }}"
api_password: "{{ gui_password }}"
register: token_result
- name: Extract the token from the result and set it as fact
set_fact:
api_token: "{{ token_result.token }}"
- name: Login by token and create a push monitor
lucasheld.uptime_kuma.monitor:
api_url: "http://{{ kuma_host }}"
api_token: "{{ api_token }}"
name: "{{ push_monitor_name }}"
type: push
interval: 60
maxretries: 0
state: present
- name: get push monitor
lucasheld.uptime_kuma.monitor_info:
api_url: "http://{{ kuma_host }}"
api_token: "{{ api_token }}"
name: "{{ push_monitor_name }}"
register: push_monitor_result
which outputs
failed: [localhost] (item=BackupScript) => {"ansible_loop_var": "item", "changed": false, "item": "BackupScript", "msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_info_payload_a5hbmzch/ansible_lucasheld.uptime_kuma.monitor_info_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_info.py\", line 302, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_info_payload_a5hbmzch/ansible_lucasheld.uptime_kuma.monitor_info_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_info.py\", line 268, in run\nAttributeError: 'list' object has no attribute 'items'\n"}
Thanks for the library, it's made things a lot easier! I'm running into an issue where invocations end up being timed out by Ansible after some kind of internal failure. My setup is somewhat simple: Uptime-Kuma is running in a docker container on fly.io.
For example, running a command like:
- name: Get Uptime Kuma push monitor info
delegate_to: 127.0.0.1
become: false
throttle: 1
lucasheld.uptime_kuma.monitor_info:
api_url: "{{ uptime_kuma_url }}"
api_token: "{{ uptime_kuma_api_token }}"
name: "{{ monitor_name }}"
I've traced this back to a timeout occurring in socketio (the log output here is my executing the ansible-generated python script manually repeatedly to try and induce the failure) and a raised exception going uncaught:
Traceback (most recent call last):
File "/Users/zac/Servers/ovh/./test.py", line 107, in <module>
_ansiballz_main()
File "/Users/zac/Servers/ovh/./test.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/zac/Servers/ovh/./test.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.lucasheld.uptime_kuma.plugins.modules.monitor_info', init_globals=dict(_module_fqn='ansible_collections.lucasheld.uptime_kuma.plugins.modules.monitor_info', _modlib_path=modlib_path),
File "/opt/homebrew/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/homebrew/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/opt/homebrew/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/var/folders/1y/9pbgc3zx1kb_1mgvd5m97xc40000gn/T/ansible_lucasheld.uptime_kuma.monitor_info_payload_ha8zoka_/ansible_lucasheld.uptime_kuma.monitor_info_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_info.py", line 404, in <module>
File "/var/folders/1y/9pbgc3zx1kb_1mgvd5m97xc40000gn/T/ansible_lucasheld.uptime_kuma.monitor_info_payload_ha8zoka_/ansible_lucasheld.uptime_kuma.monitor_info_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor_info.py", line 381, in main
File "/Users/zac/Servers/ovh/.venv/lib/python3.10/site-packages/uptime_kuma_api/api.py", line 2552, in login_by_token
return self._call('loginByToken', token)
File "/Users/zac/Servers/ovh/.venv/lib/python3.10/site-packages/uptime_kuma_api/api.py", line 480, in _call
r = self.sio.call(event, data)
File "/Users/zac/Servers/ovh/.venv/lib/python3.10/site-packages/socketio/client.py", line 471, in call
raise exceptions.TimeoutError()
socketio.exceptions.TimeoutError
I added some logging around the call site in api.py
:
https://github.com/lucasheld/uptime-kuma-api/blob/master/uptime_kuma_api/api.py#L478-L484
What's happening appears to be the loginByToken
call attempts to occur, but times out. Weirdly, I do see this request coming through on the Uptime Kuma side:
2023-02-18T17:27:19Z app[21342cbf] sjc [info]2023-02-18T09:27:19-08:00 [AUTH] INFO: Login by token. IP=<snip>
2023-02-18T17:27:19Z app[21342cbf] sjc [info]2023-02-18T09:27:19-08:00 [AUTH] INFO: Username from JWT: <snip>
2023-02-18T17:27:19Z app[21342cbf] sjc [info]2023-02-18T09:27:19-08:00 [AUTH] INFO: Successfully logged in user <snip>. IP=<snip>
When this occurs, I see the _send
call begin, but it never returns until it raises the exception, which doesn't appear to be caught successfully. The end result is the python script hangs indefinitely and ends up being killed by Ansible after the timeout, rather than sending the error up the stack.
So perhaps 2 things here:
First of all thanks for this fantastic collection/module!!! :-)
I want to create a monitor type group in lucasheld.uptime_kuma.monitor, but I don't see type: group in the documentation. I see that I can add monitor to parent (and its work great), but I don't see how ti create a group monitor.
How we create a monitor group? Its supported or its planned for future support?
Thanks!
Hi, first of all I would like to thank you for this collection, it has been very useful for me and has saved a huge amount of time, really appreciate your work.
While configuring my server I found a probable bug related to setting multiple notifications for monitors. The thing is that if I already have a monitor with just one notification rule enabled, then when I try to enable two or more notification rules using playbook task, the task crashes with an error. At the same time, if I manually disable this single notification rule or delete a monitor, the task enables multiple notification rules. Thus switching one -> multiple notifications does not work, but zero -> multiple, and multiple -> one works. I attach the error log below.
I will be glad to help if you need any more information or help in fixing it. Thanks!
The full traceback is:
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 578, in main
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 425, in run
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/module_utils/common.py", line 28, in object_changed
if value[i] != value2[i]:
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"accepted_statuscodes": [
"200-299"
],
"api_headers": null,
"api_password": null,
"api_ssl_verify": true,
"api_timeout": 10.0,
"api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"api_url": "http://XXXXXX",
"api_username": null,
"api_wait_events": 0.2,
"authDomain": null,
"authMethod": null,
"authWorkstation": null,
"basic_auth_pass": null,
"basic_auth_user": null,
"body": null,
"databaseConnectionString": null,
"databaseQuery": null,
"description": null,
"dns_resolve_server": null,
"dns_resolve_type": null,
"docker_container": null,
"docker_host": null,
"expectedValue": null,
"expiryNotification": null,
"game": null,
"gamedigGivenPortOnly": null,
"grpcBody": null,
"grpcEnableTls": null,
"grpcMetadata": null,
"grpcMethod": null,
"grpcProtobuf": null,
"grpcServiceName": null,
"grpcUrl": null,
"headers": null,
"hostname": null,
"httpBodyEncoding": null,
"id": null,
"ignoreTls": null,
"interval": null,
"invertKeyword": null,
"jsonPath": null,
"kafkaProducerAllowAutoTopicCreation": null,
"kafkaProducerBrokers": null,
"kafkaProducerMessage": null,
"kafkaProducerSaslOptions": null,
"kafkaProducerSsl": null,
"kafkaProducerTopic": null,
"keyword": null,
"maxredirects": null,
"maxretries": null,
"method": null,
"mqttPassword": null,
"mqttSuccessMessage": null,
"mqttTopic": null,
"mqttUsername": null,
"name": "Google",
"notificationIDList": [
8,
9
],
"oauth_auth_method": null,
"oauth_client_id": null,
"oauth_client_secret": null,
"oauth_scopes": null,
"oauth_token_url": null,
"packetSize": null,
"parent": 3,
"port": null,
"proxyId": null,
"radiusCalledStationId": null,
"radiusCallingStationId": null,
"radiusPassword": null,
"radiusSecret": null,
"radiusUsername": null,
"resendInterval": null,
"retryInterval": null,
"state": "present",
"timeout": null,
"tlsCa": null,
"tlsCert": null,
"tlsKey": null,
"type": "http",
"upsideDown": null,
"url": "https://google.com"
}
},
"msg": "Traceback (most recent call last):\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py\", line 578, in main\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py\", line 425, in run\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_zfr4xyx_/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/module_utils/common.py\", line 28, in object_changed\n if value[i] != value2[i]:\nIndexError: list index out of range\n"
}
Versions:
Consider the following task:
- name: Configure status page as entry page
lucasheld.uptime_kuma.settings:
api_url: https://{{ status_url }}
api_token: "{{ api_token }}"
entryPage: "1uhosting"
The entry page "1uhosting" gets configured but the selection of the radio button within the web UI is missing:
Is there another setting available to configure this selection or is this behavior a bug?
What happened:
When creating a status page, multiple monitors can be added in the monitorList
section. However, after executing the playbook, only the first monitor is added into the group in UptimeKuma
Expected result:
Multiple monitors to be created, after being added in the monitorList
Sample code:
- name: Add status page with monitor
lucasheld.uptime_kuma.status_page:
api_url: "{{ kuma_api }}"
api_token: "{{ kuma_api_token }}"
slug: page-status
title: 'Status Page'
publicGroupList:
- name: 'Page Status Monitors'
weight: 1
monitorList:
- name: monitor_1
- name: monitor_2
Trying to figure out how to add a notification to a particular monitor task in ansible so that it can all be generated at the same time. Any ideas?
An example task I'm working on:
- name: Add SSL check for all domain certificates
lucasheld.uptime_kuma.monitor:
api_url: "{{ kuma_api_url }}"
api_token: "{{ api_token }}"
name: "SSL Verify: {{ item }}"
url: https://{{ item }}
type: http
expiryNotification: true
state: present
interval: 86400
tags:
- kuma_monitors
I want to create a slack notification via a webhook. Does the slack notification need to be created first and register the output to grab an id from it and then add that to the above task? Going to try and test via this documentation https://github.com/lucasheld/ansible-uptime-kuma/wiki/monitor_info with notificationIDList
that currently is the only thing I'm seeing that might be the route I should be taking.
I plan to add a debug task after the notification task is ran to see if it gives me an id, if so then will add that to a task via the notificationIDList
.
I also posted this question here sorry if this doesn't exactly fit here but wasn't sure where else I could post and get a response.
When trying to use the maintenance module, I get the following error
PLAY [Start maintenance] ************************************************************************************************************************************************************************************************************************************************************
TASK [Resume maintenance] ***********************************************************************************************************************************************************************************************************************************************************
Monday 09 January 2023 20:07:09 +0000 (0:00:00.047) 0:00:00.047 ********
Monday 09 January 2023 20:07:09 +0000 (0:00:00.043) 0:00:00.043 ********
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (uptime_kuma_api) on 7b746f49e7d9's Python /usr/local/bin/python3.11. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
PLAY RECAP **************************************************************************************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
After removing the try around the import statement in the module, I have got the following error:
ImportError: cannot import name 'MaintenanceType' from 'uptime_kuma_api'
PLAY [Start maintenance] ************************************************************************************************************************************************************************************************************************************************************
TASK [Resume maintenance] ***********************************************************************************************************************************************************************************************************************************************************
Monday 09 January 2023 20:06:30 +0000 (0:00:00.047) 0:00:00.047 ********
Monday 09 January 2023 20:06:30 +0000 (0:00:00.044) 0:00:00.044 ********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: cannot import name 'MaintenanceType' from 'uptime_kuma_api' (/usr/local/lib/python3.11/site-packages/uptime_kuma_api/__init__.py)
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1673294790.7070203-123-155382996944439/AnsiballZ_maintenance.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1673294790.7070203-123-155382996944439/AnsiballZ_maintenance.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1673294790.7070203-123-155382996944439/AnsiballZ_maintenance.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.lucasheld.uptime_kuma.plugins.modules.maintenance', init_globals=dict(_module_fqn='ansible_collections.lucasheld.uptime_kuma.plugins.modules.maintenance', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_lucasheld.uptime_kuma.maintenance_payload_9rmidi5k/ansible_lucasheld.uptime_kuma.maintenance_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/maintenance.py\", line 156, in <module>\nImportError: cannot import name 'MaintenanceType' from 'uptime_kuma_api' (/usr/local/lib/python3.11/site-packages/uptime_kuma_api/__init__.py)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
PLAY RECAP **************************************************************************************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Version:
/ # ansible --version
ansible [core 2.14.1]
config file = /data/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.11.1 (main, Dec 8 2022, 01:03:47) [GCC 12.2.1 20220924] (/usr/local/bin/python3)
jinja version = 3.1.2
libyaml = False
Uptime Kuma: 1.21.2
Ansible: 2.10.7
Hi when i try use playbook like this:
- hosts: ansible
tasks:
- name: Login by token and create a monitor
lucasheld.uptime_kuma.monitor:
api_url: http://192.168.10.25:3001
api_username: admin
api_password: secret123
name: Goojkhgle
type: http
url: https://google.com
state: present
Error in output:
TASK [Login by token and create a monitor] ******************************************************************
task path: /home/ansible/ansible_dir/playbooks/uptimekuma.yml:3
<ansible> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<ansible> EXEC /bin/sh -c 'echo ~ansible && sleep 0'
<ansible> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp `"&& mkdir "` echo /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787 `" && echo ansible-tmp-1681983688.5391455-59112-150114658119787="` echo /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787 `" ) && sleep 0'
Using module file /home/ansible/.ansible/collections/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py
<ansible> PUT /home/ansible/.ansible/tmp/ansible-local-590185knhddhd/tmp5m13g9jk TO /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py
<ansible> EXEC /bin/sh -c 'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/ /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py && sleep 0'
<ansible> EXEC /bin/sh -c '/usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py && sleep 0'
<ansible> EXEC /bin/sh -c 'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py", line 102, in <module>
_ansiballz_main()
File "/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.lucasheld.uptime_kuma.plugins.modules.monitor', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/lib/python2.7/runpy.py", line 188, in run_module
fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_TtsHb4/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py", line 291, in <module>
File "/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_TtsHb4/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/module_utils/common.py", line 39
def clear_params(params: dict):
^
SyntaxError: invalid syntax
fatal: [ansible]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1681983688.5391455-59112-150114658119787/AnsiballZ_monitor.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.lucasheld.uptime_kuma.plugins.modules.monitor', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_TtsHb4/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/modules/monitor.py\", line 291, in <module>\n File \"/tmp/ansible_lucasheld.uptime_kuma.monitor_payload_TtsHb4/ansible_lucasheld.uptime_kuma.monitor_payload.zip/ansible_collections/lucasheld/uptime_kuma/plugins/module_utils/common.py\", line 39\n def clear_params(params: dict):\n ^\nSyntaxError: invalid syntax\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Stuck while associating tags with monitors. it gets stuck at different monitors every time I run the playbook. I think API is getting stuck or failed
Hi, thanks first for the great role.
I tried to configure my uptime kuma instance with your role and found out, that it seems not to be possible if 2FA is activated.
As far as I understand, the option to use an api-token only works with the session token one receive after use the normal login method with password. I tried to generate an API token via Web UI and use this in the ansible role but it did not work out.
If you activate 2FA, then the above described process will not work because the initial login with password will fail. In the uptime kuma logs the error message is:
[AUTH] INFO: 2FA token required for user admin. IP=127.0.0.1
So it would be great and from security pint of view recommended to are able to use an api token generated in the web ui for ansible and activate 2FA for the Dashboard login.
Hi,
I might be misunderstanding something with ansible. But I would like to have my status page made a little simpler than manually adding a block for every service that I have added.
Current I have a vars.yml
monitor_http:
- name: "Google"
url: "https://google.com"
ignoreTLS: false
- name: "Service Internal"
url: 'http://192.168.1.1/'
ignoreTLS: true
in my tasks/main.yml
i have
- name: Login by token and create a monitor
lucasheld.uptime_kuma.monitor:
api_url: "{{ kuma_api }}"
api_token: "{{ api_token }}"
name: "{{ item.name}}"
type: http
ignoreTls: "{{ item.ignoreTLS }}"
url: "{{ item.url }}"
state: present
with_items: "{{ monitor_http }}"
Which correctly creates a monitoring per entry in vars.yml
.
But when I try to do the same for my status page, it doesn't work, it adds the last entry on the vars.yml
- name: Add status page
lucasheld.uptime_kuma.status_page:
api_url: "{{ kuma_api }}"
api_token: "{{ api_token }}"
slug: default
title: default
state: present
publicGroupList:
- name: "{{ item.name }}"
weight: 1
monitorList:
- name: "{{ item.name }}"
with_items: "{{ monitor_http }}"
I have tried to move the with_items
to have it in PublicGroupList
and MonitorList
, neither worked. Any input here on how to solve this?
The choice in the module for adding a monitor only accepts empty, basic or ntlm. When trying to add a new monitor using mtls authentication the play fails.
A 4th choice, mtls needs to be added.
I fixed this locally:
lucasheld/uptime_kuma/plugins/modules/monitor.py
, line 406
From:
authMethod=dict(type="str", choices=["", "basic", "ntlm"]),
To:
authMethod=dict(type="str", choices=["", "basic", "ntlm", "mtls"]),
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.