mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2026-03-13 13:42:47 +01:00
build
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
zabbix_db_file: "/var/lib/zabbix/zabbix_proxy.db"
|
zabbix_db_file: "/var/lib/zabbix/zabbix_proxy.db"
|
||||||
zabbix_db_type: "sqlite" # sqlite | mysql | postgres
|
zabbix_db_type: "sqlite" # sqlite | mysql | postgres
|
||||||
zabbix_api_url: "https://zabbix.sectorq.eu/api_jsonrpc.php"
|
zabbix_api_url: "https://zabbix.sectorq.eu/api_jsonrpc.php"
|
||||||
clustename: debian
|
|
||||||
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
||||||
block:
|
block:
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
@@ -15,6 +15,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
|
- name: Set proxy name
|
||||||
|
set_fact:
|
||||||
|
clustename: "debian"
|
||||||
|
|
||||||
- name: Show default IP
|
- name: Show default IP
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ ansible_default_ipv4.address }}"
|
msg: "{{ ansible_default_ipv4.address }}"
|
||||||
@@ -182,101 +186,3 @@
|
|||||||
name: zabbix-agent2
|
name: zabbix-agent2
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- 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: Print proxygroup_check1
|
|
||||||
debug:
|
|
||||||
msg: "{{ proxygroup_check.json.result[0].proxy_groupid }}"
|
|
||||||
run_once: true
|
|
||||||
|
|
||||||
|
|
||||||
- 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: "5m"
|
|
||||||
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: Print proxygroup_check2
|
|
||||||
debug:
|
|
||||||
msg: "{{ proxygroup_check.json.result[0].proxy_groupid }}"
|
|
||||||
run_once: true
|
|
||||||
|
|
||||||
- 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: "{{ zabbix_proxy_name }}"
|
|
||||||
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: "{{ zabbix_proxy_name }}"
|
|
||||||
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 }}"
|
|
||||||
@@ -18,6 +18,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
|
- name: Set proxy name
|
||||||
|
set_fact:
|
||||||
|
clustename: "rocky"
|
||||||
|
|
||||||
- name: Show default IP
|
- name: Show default IP
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ ansible_default_ipv4.address }}"
|
msg: "{{ ansible_default_ipv4.address }}"
|
||||||
@@ -320,3 +324,6 @@
|
|||||||
- name: Print proxy_check
|
- name: Print proxy_check
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ proxy_check2 }}"
|
msg: "{{ proxy_check2 }}"
|
||||||
|
|
||||||
|
- name: Create hosts / proxies in zabbix
|
||||||
|
ansible.builtin.include_tasks: "configure.yml"
|
||||||
|
|||||||
Reference in New Issue
Block a user