ansible-uptime-kuma
ansible-uptime-kuma copied to clipboard
lucasheld.uptime_kuma.status_page errors on latest uptime kuma version
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.
Update
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