Change kuma task
This commit is contained in:
parent
5237aadddb
commit
edb8b400fc
|
@ -54,71 +54,6 @@
|
|||
- vhost
|
||||
register: vhost_changed
|
||||
|
||||
- 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:
|
||||
- vhost
|
||||
- kuma
|
||||
|
||||
- name: Extract the token from the result and set it as fact
|
||||
set_fact:
|
||||
api_token: "{{ result.token }}"
|
||||
tags:
|
||||
- vhost
|
||||
- kuma
|
||||
|
||||
- name: Login by token and create a monitor
|
||||
lucasheld.uptime_kuma.monitor:
|
||||
api_url: https://kuma.dryusdan.net
|
||||
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:
|
||||
- vhost
|
||||
- kuma
|
||||
|
||||
- name: Create a website tag on monitor
|
||||
lucasheld.uptime_kuma.monitor_tag:
|
||||
api_url: https://kuma.dryusdan.net
|
||||
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:
|
||||
- vhost
|
||||
|
||||
- name: "Create certificate"
|
||||
shell: "certbot certonly --non-interactive --webroot --email {{ nginx_letsencrypt_email }} --agree-tos --webroot-path=/var/www/letsencrypt {% for domain in item.server_name %} -d {{ domain }} {% endfor %} --expand --rsa-key-size 4096;"
|
||||
when:
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
- 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
|
||||
|
|
@ -19,6 +19,10 @@
|
|||
tags:
|
||||
- vhost
|
||||
|
||||
- include_tasks: kuma.yml
|
||||
tags:
|
||||
- kuma
|
||||
|
||||
- include_tasks: create-webcheck-zabbix.yml
|
||||
tags:
|
||||
- zabbix
|
||||
|
|
Loading…
Reference in New Issue