This commit is contained in:
2026-02-17 10:59:51 +01:00
parent 9505fe5d05
commit 861d05472b

View File

@@ -14,14 +14,13 @@
headers: headers:
Content-Type: "application/json" Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}" Authorization: "Bearer {{ zabbix_auth_token }}"
register: proxygroup_check register: proxygroup_query
run_once: true # Run this task only once run_once: true # Run this task only once
- name: Print proxy_check - name: Print proxygroup_query
debug: debug:
msg: "{{ proxygroup_check }}" msg: "{{ proxygroup_query }}"
run_once: true # Run this task only once run_once: true # Run this task only once
when: proxygroup_check.json.result | length != 0
- name: Create proxy group if not exists - name: Create proxy group if not exists
uri: uri:
@@ -39,14 +38,24 @@
headers: headers:
Content-Type: "application/json" Content-Type: "application/json"
Authorization: "Bearer {{ zabbix_auth_token }}" Authorization: "Bearer {{ zabbix_auth_token }}"
when: proxygroup_check.json.result | length == 0 when: proxygroup_query.json.result | length == 0
register: proxygroup_check register: proxygroup_create
run_once: true # Run this task only once run_once: true # Run this task only once
- name: Print proxygroup_check - name: Print proxygroup_create
debug: debug:
msg: "{{ proxygroup_check }}" msg: "{{ proxygroup_create }}"
run_once: true # Run this task only once run_once: true # Run this task only once
when: proxygroup_create.json.result | length != 0
- set_fact:
proxygroup_id: >-
{{
proxygroup_create.json.result.proxy_groupid[0]
if not proxygroup_create.skipped
else proxygroup_query.json.result[0].proxy_groupid
}}
- name: Check if proxy exists - name: Check if proxy exists
@@ -82,7 +91,7 @@
method: "proxy.create" method: "proxy.create"
params: params:
name: "{{ inventory_hostname }}" name: "{{ inventory_hostname }}"
proxy_groupid: "{{ proxygroup_check.json.result[0].proxy_groupid }}" proxy_groupid: "{{ proxygroup_id }}"
operating_mode: 0 operating_mode: 0
local_address: "{{ ansible_default_ipv4.address }}" local_address: "{{ ansible_default_ipv4.address }}"
port: "10051" port: "10051"