blob: ccabc31d9af2fa9bbc7dd04617865b2c0f868033 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
---
- when:
- ansible_distribution == 'Ubuntu'
block:
- name: Create a new Zabbix template.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
template_groups:
- 'Linux servers'
- 'Templates'
state: present
register: create_zabbix_template_result
- assert:
that:
- create_zabbix_template_result.changed is sameas true
- name: Gather Zabbix template infomation.
zabbix_template_info:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
format: json
register: gather_template_result
- assert:
that:
- gather_template_result.template_json.zabbix_export.groups.0.name == 'Linux servers'
- gather_template_result.template_json.zabbix_export.groups.1.name == 'Templates'
- name: Add link_templates to Zabbix template.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
template_groups:
- 'Linux servers'
- 'Templates'
link_templates:
- 'Template App Zabbix Proxy'
- 'Template Module Zabbix agent'
state: present
register: update_zabbix_template_result
- assert:
that:
- create_zabbix_template_result.changed is sameas true
- name: Gather Zabbix template infomation.
zabbix_template_info:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
format: json
register: gather_template_result
- assert:
that:
- gather_template_result.template_json.zabbix_export.groups.0.name == 'Linux servers'
- gather_template_result.template_json.zabbix_export.groups.1.name == 'Templates'
- gather_template_result.template_json.zabbix_export.templates.0.templates.0.name == 'Template App Zabbix Proxy'
- gather_template_result.template_json.zabbix_export.templates.0.templates.1.name == 'Template Module Zabbix agent'
- name: Add macros to Zabbix template.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
template_groups:
- 'Linux servers'
- 'Templates'
link_templates:
- 'Template App Zabbix Proxy'
- 'Template Module Zabbix agent'
macros:
- macro: '{$EXAMPLE_MACRO1}'
value: 1000
- macro: '{$EXAMPLE_MACRO2}'
value: 'text'
state: present
register: update_zabbix_template_result
- assert:
that:
- create_zabbix_template_result.changed is sameas true
- name: Gather Zabbix template infomation.
zabbix_template_info:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
format: json
register: gather_template_result
- assert:
that:
- gather_template_result.template_json.zabbix_export.groups.0.name == 'Linux servers'
- gather_template_result.template_json.zabbix_export.groups.1.name == 'Templates'
- gather_template_result.template_json.zabbix_export.templates.0.templates.0.name == 'Template App Zabbix Proxy'
- gather_template_result.template_json.zabbix_export.templates.0.templates.1.name == 'Template Module Zabbix agent'
- gather_template_result.template_json.zabbix_export.templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}'
- gather_template_result.template_json.zabbix_export.templates.0.macros.0.value == '1000'
- gather_template_result.template_json.zabbix_export.templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}'
- gather_template_result.template_json.zabbix_export.templates.0.macros.1.value == 'text'
- name: Dump Zabbix template to XML format.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
dump_format: xml
state: dump
register: template_dump_result
- debug: var=template_dump_result
- assert:
that:
- template_dump_result.deprecations is defined
- template_dump_result.deprecations.0.version == '2.14'
- name: Dump Zabbix template to JSON format.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
dump_format: json
state: dump
register: template_dump_result
- debug: var=template_dump_result
- assert:
that:
- template_dump_result.deprecations is defined
- template_dump_result.deprecations.0.version == '2.14'
- name: Delete Zabbix template.
zabbix_template:
server_url: "{{ zabbix_server_url }}"
login_user: "{{ zabbix_login_user }}"
login_password: "{{ zabbix_login_password }}"
template_name: ExampleHost
state: absent
register: delete_zabbix_template_result
- assert:
that:
- delete_zabbix_template_result.changed is sameas true
|