-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_zabbix_hostmacro.yml
68 lines (62 loc) · 2.04 KB
/
test_zabbix_hostmacro.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- hosts: all
name: Run various tests with zabbix_host and zabbix_hostmacro modules
vars:
zbx_host_macros:
- key: LOW_SPACE_LIMIT:/home
value: 10
tasks:
- block:
- name: Create host in zabbix
zabbix_host:
server_url: '{{ zbx_server_url }}'
login_user: '{{ zbx_user }}'
login_password: '{{ zbx_password }}'
host_name: '{{ inventory_hostname }}'
visible_name: '{{ inventory_hostname }}'
validate_certs: '{{ zbx_validate_certs }}'
force: no
host_groups:
- Linux servers
link_templates:
- '{{ zbx_icmp_template }}'
status: enabled
state: present
inventory_mode: disabled
interfaces:
- type: 1
main: 1
useip: 0
ip: "{{ ansible_default_ipv4.address }}"
dns: "{{ inventory_hostname }}"
port: 10050
- name: Create host macros (new)
zabbix_hostmacro:
server_url: '{{ zbx_server_url }}'
login_user: '{{ zbx_user }}'
login_password: '{{ zbx_password }}'
validate_certs: '{{ zbx_validate_certs }}'
host_name: '{{ inventory_hostname }}'
macro_name: '{{ item.key }}'
macro_value: '{{ item.value }}'
state: present
loop: '{{ zbx_host_macros }}'
register: _macros_new
- assert:
that:
- _macros_new.changed
- name: Create host macros (existing)
zabbix_hostmacro:
server_url: '{{ zbx_server_url }}'
login_user: '{{ zbx_user }}'
login_password: '{{ zbx_password }}'
validate_certs: '{{ zbx_validate_certs }}'
host_name: '{{ inventory_hostname }}'
macro_name: '{{ item.key }}'
macro_value: '{{ item.value }}'
state: present
loop: '{{ zbx_host_macros }}'
register: _macros_new
- assert:
that:
- not _macros_new.changed
delegate_to: localhost