Closed yurinek closed 1 year ago
Thanks for your report. This is an uptime-kuma-api issue.
The bug is fixed in uptime-kuma-api 0.2.1 (https://github.com/lucasheld/uptime-kuma-api/commit/12cd8067e469d83912fd8417ffb768c3d7572887)
Now the pushToken
is generated when a monitor is saved.
It is expected that the url
is unset. This url is only used for http
and keyword
monitor types. The push url must be generated from the pushToken as follows: "http://{{ kuma_host }}/api/push/{{ pushToken }}?status=up&msg=OK&ping="
now the new issue is that none of Return Values work except "monitors" key. e.g.
- 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
- name: debug 2
debug: msg="{{ push_monitor_result.pushToken }}"
with
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'pushToken
same error for other return keys except push_monitor_result.monitors
The monitor_info module returns a list of monitors. If you specifiy a monitor name
or id
, the list contains only one entry. Otherwise the list contains all available monitors. The list is stored in the value of the monitors
key.
In your case, the requested monitor is the first entry in the list (index 0). You can use this entry to access the pushToken
.
- name: add 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
- set_fact:
monitor_push_token: "{{ push_monitor_result.monitors[0].pushToken }}"
- set_fact:
monitor_push_url: "http://{{ kuma_host }}/api/push/{{ monitor_push_token }}?status=up&msg=OK&ping="
- debug:
var: monitor_push_token
- debug:
var: monitor_push_url
Hello,
we need to parse pushToken and url to use it in our scripts to push messages to a push-monitor.
however the above outputs Null for these return values