summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_correlation/tasks/main.yml
blob: d893cbc34b44a9defa1232189718ad674ec54f09 (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
---
- name: test - create simple correlation
  community.zabbix.zabbix_correlation:
    name: new event tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag
          tag: ok
    operations:
      - type: close_old_events
  register: zbxcorrelation_create

- name: assert that correlation was created
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas True

- name: test - update simple correlation (without changes)
  community.zabbix.zabbix_correlation:
    name: new event tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag
          tag: ok
    operations:
      - type: close_old_events
  register: zbxcorrelation_create

- name: assert that correlation was not updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas False

- name: test - update simple correlation
  community.zabbix.zabbix_correlation:
    name: new event tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag
          tag: ng
    operations:
      - type: close_old_events
  register: zbxcorrelation_create

- name: assert that correlation was updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas True

- name: test - delete simple correlation
  community.zabbix.zabbix_correlation:
    name: new event tag correlation
    state: absent
  register: zbxcorrelation_delete

- name: assert that correlation was deleted
  ansible.builtin.assert:
    that:
      - zbxcorrelation_delete.changed is sameas True

- name: prepare - create hostgroup
  community.zabbix.zabbix_group:
    host_groups:
      - correlation_group_A
      - correlation_group_B
    state: present
  register: zbxgroup_create

- name: test - create custom_expression correlation
  community.zabbix.zabbix_correlation:
    name: new host group correlation
    description: a custom description
    filter:
      evaltype: custom_expression
      formula: A or B
      conditions:
        - type: new_event_host_group
          hostgroup: correlation_group_A
          operator: not_equal
          formulaid: A
        - type: new_event_host_group
          hostgroup: correlation_group_B
          operator: not_equal
          formulaid: B
    operations:
      - type: close_old_events
  register: zbxcorrelation_create

- name: assert that correlation was created
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas True

- name: test - create custom_expression correlation (again)
  community.zabbix.zabbix_correlation:
    name: new host group correlation
    description: a custom description
    filter:
      evaltype: custom_expression
      formula: A or B
      conditions:
        - type: new_event_host_group
          hostgroup: correlation_group_A
          operator: not_equal
          formulaid: A
        - type: new_event_host_group
          hostgroup: correlation_group_B
          operator: not_equal
          formulaid: B
    operations:
      - type: close_old_events
  register: zbxcorrelation_create

- name: assert that correlation was not updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas False

- name: test - delete custom_expression correlation
  community.zabbix.zabbix_correlation:
    name: new host group correlation
    state: absent
  register: zbxcorrelation_delete

- name: assert that correlation was deleted
  ansible.builtin.assert:
    that:
      - zbxcorrelation_delete.changed is sameas True

- name: cleanup - delete hostgroup
  community.zabbix.zabbix_group:
    host_groups:
      - correlation_group_A
      - correlation_group_B
    state: absent
  register: zbxgroup_delete

- name: test - create correlation with old_event_tag condition
  community.zabbix.zabbix_correlation:
    name: tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: old_event_tag
          tag: old_tag
    operations:
      - type: close_old_events
      - type: close_new_event
  register: zbxcorrelation_create

- name: assert that correlation was created
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create.changed is sameas True

- name: test - update correlation with new_event_tag condition
  community.zabbix.zabbix_correlation:
    name: tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag
          tag: new_tag
    operations:
      - type: close_old_events
      - type: close_new_event
  register: zbxcorrelation_update

- name: assert that correlation was updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_update.changed is sameas True

- name: test - update correlation with event_tag_pair condition
  community.zabbix.zabbix_correlation:
    name: tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: event_tag_pair
          oldtag: oldtag_pair
          newtag: newtag_pair
    operations:
      - type: close_old_events
      - type: close_new_event
  register: zbxcorrelation_update

- name: assert that correlation was updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_update.changed is sameas True

- name: test - update correlation with old_event_tag_value condition
  community.zabbix.zabbix_correlation:
    name: tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: old_event_tag_value
          tag: old_tag_value
          value: old
          operator: equal
    operations:
      - type: close_old_events
      - type: close_new_event
  register: zbxcorrelation_update

- name: assert that correlation was updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_update.changed is sameas True

- name: test - update correlation with new_event_tag_value condition
  community.zabbix.zabbix_correlation:
    name: tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag_value
          tag: new_tag_value
          value: new
          operator: equal
    operations:
      - type: close_old_events
      - type: close_new_event
  register: zbxcorrelation_update

- name: assert that correlation was updated
  ansible.builtin.assert:
    that:
      - zbxcorrelation_update.changed is sameas True

- name: test - delete tag correlation
  community.zabbix.zabbix_correlation:
    name: tag correlation
    state: absent
  register: zbxcorrelation_delete

- name: assert that correlation was deleted
  ansible.builtin.assert:
    that:
      - zbxcorrelation_delete.changed is sameas True

- name: prepare - create hostgroup
  community.zabbix.zabbix_group:
    host_groups:
      - correlation_group
    state: present
  register: zbxgroup_create

- name: test - create host group correlation with wrong operator (like)
  community.zabbix.zabbix_correlation:
    name: new host group correlation
    description: a custom description
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_host_group
          hostgroup: correlation_group
          operator: like
    operations:
      - type: close_old_events
  ignore_errors: yes
  register: zbxcorrelation_create

- name: assert that correlation was failed
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create is failed

- name: test - create host group correlation with wrong operator (not_like)
  community.zabbix.zabbix_correlation:
    name: new host group correlation
    description: a custom description
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_host_group
          hostgroup: correlation_group
          operator: not_like
    operations:
      - type: close_old_events
  ignore_errors: yes
  register: zbxcorrelation_create

- name: assert that correlation was failed
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create is failed

- name: prepare - delete hostgroup
  community.zabbix.zabbix_group:
    host_groups:
      - correlation_group
    state: absent
  register: zbxgroup_delete

- name: test - create tag correlation with wrong formulaid
  community.zabbix.zabbix_correlation:
    name: new tag correlation
    description: a custom description
    filter:
      evaltype: custom_expression
      formula: a
      conditions:
        - type: new_event_tag_value
          tag: new_tag_value
          value: new
          operator: equal
          formulaid: a
    operations:
      - type: close_old_events
  ignore_errors: yes
  register: zbxcorrelation_create

- name: assert that correlation was failed
  ansible.builtin.assert:
    that:
      - zbxcorrelation_create is failed

- name: test - delete custom_expression correlation
  community.zabbix.zabbix_correlation:
    name: new tag correlation
    state: absent
  register: zbxcorrelation_delete