64 lines
1.6 KiB
YAML
64 lines
1.6 KiB
YAML
---
|
||
- name: Login with credentials once and register the result
|
||
lucasheld.uptime_kuma.login:
|
||
api_url: "{{ kuma_url }}"
|
||
api_username: "{{ kuma_username }}"
|
||
api_password: "{{ kuma_password }}"
|
||
register: result
|
||
become: yes
|
||
become_user : "ansible"
|
||
become_method: su
|
||
become_flags: '-s /bin/bash'
|
||
delegate_to: "127.0.0.1"
|
||
tags:
|
||
- kuma
|
||
|
||
- name: Extract the token from the result and set it as fact
|
||
set_fact:
|
||
api_token: "{{ result.token }}"
|
||
tags:
|
||
- kuma
|
||
|
||
- name: Login by token and create a monitor
|
||
lucasheld.uptime_kuma.monitor:
|
||
api_url: "{{ kuma_url }}"
|
||
api_token: "{{ api_token }}"
|
||
name: "{{ item.monitoring_name }}"
|
||
type: http
|
||
url: "{{ item.monitoring_url }}"
|
||
expiryNotification: True
|
||
interval: 30
|
||
maxredirects: 0
|
||
maxretries: 3
|
||
accepted_statuscodes: "{{ item.monitoring_statuscode | default('200-299') }}"
|
||
state: present
|
||
loop: "{{ nginx_vhost }}"
|
||
become: yes
|
||
become_user : "ansible"
|
||
become_method: su
|
||
become_flags: '-s /bin/bash'
|
||
delegate_to: "127.0.0.1"
|
||
when:
|
||
- item.state == "present" or item.state is not defined
|
||
tags:
|
||
- kuma
|
||
|
||
- name: Create a website tag on monitor
|
||
lucasheld.uptime_kuma.monitor_tag:
|
||
api_url: "{{ kuma_url }}"
|
||
api_token: "{{ api_token }}"
|
||
monitor_name: "{{ item.monitoring_name }}"
|
||
tag_name: Website
|
||
state: present
|
||
loop: "{{ nginx_vhost }}"
|
||
become: yes
|
||
become_user : "ansible"
|
||
become_method: su
|
||
become_flags: '-s /bin/bash'
|
||
delegate_to: "127.0.0.1"
|
||
when:
|
||
- item.state == "present" or item.state is not defined
|
||
tags:
|
||
- kuma
|
||
|