lucasheld / ansible-uptime-kuma

Ansible collection of modules to configure Uptime Kuma
GNU General Public License v3.0
135 stars 19 forks source link

Unable to change monitor notifications from one to multiple #43

Open Yabzik opened 7 months ago

Yabzik commented 7 months ago

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:

obfusk commented 6 months ago

Looks like the same bug #38 fixes.

gothchibjo commented 4 months ago

Hello guys! Is there a chance to fix the bug with the monitors' notification channel replacement? It's definitely annoying to rebuild a monitor (and lose its stats) if I want to replace only one channel in a list of the monitor's channels.