nginx/tasks/kuma.yml

64 lines
1.6 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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