Files
ansible/roles/zabbix_proxy/tasks/configure.yml
jaydee 64872780a5
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
build
2026-02-17 09:53:48 +01:00

89 lines
2.1 KiB
YAML

---
- name: Check if proxy group exists
uri:
url: "{{ zabbix_api_url }}"
method: POST
body_format: json
body:
jsonrpc: "2.0"
method: "proxygroup.get"
params:
filter:
name: "{{ clustename }}"
id: 2
headers:
Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}"
register: proxygroup_check
run_once: true # Run this task only once
- name: Create proxy group if not exists
uri:
url: "{{ zabbix_api_url }}"
method: POST
body_format: json
body:
jsonrpc: "2.0"
method: "proxygroup.create"
params:
name: "{{ clustename }}"
failover_delay: "1m"
min_online: 1
id: 1
headers:
Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}"
when: proxygroup_check.json.result | length == 0
register: proxygroup_check2
run_once: true # Run this task only once
- name: Check if proxy exists
uri:
url: "{{ zabbix_api_url }}"
method: POST
body_format: json
body:
jsonrpc: "2.0"
method: "proxy.get"
params:
filter:
name: "{{ inventory_hostname }}"
id: 2
headers:
Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}"
register: proxy_check
- name: Print proxy_check
debug:
msg: "{{ proxy_check }}"
- name: Create proxy if not exists
uri:
url: "{{ zabbix_api_url }}"
method: POST
body_format: json
body:
jsonrpc: "2.0"
method: "proxy.create"
params:
name: "{{ inventory_hostname }}"
proxy_groupid: "{{ proxygroup_check.json.result[0].proxy_groupid }}"
operating_mode: 0
local_address: "{{ ansible_default_ipv4.address }}"
port: "10051"
id: 3
headers:
Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}"
when: proxy_check.json.result | length == 0
register: proxy_check2
- name: Print proxy_check
debug:
msg: "{{ proxy_check2 }}"