Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/wafv2_rule_group/tasks/main.yml

raw
1 ---
2 - module_defaults:
3 group/aws:
4 access_key: "{{ aws_access_key }}"
5 secret_key: "{{ aws_secret_key }}"
6 session_token: "{{ security_token | default(omit) }}"
7 region: "{{ aws_region }}"
8 block:
9 ####################################
10 # Create and test rule group
11 ####################################
12 - name: check_mode create rule group
13 wafv2_rule_group:
14 name: "{{ rule_group_name }}"
15 state: present
16 description: hallo eins
17 scope: REGIONAL
18 capacity: 500
19 rules:
20 - name: eins
21 priority: 1
22 action:
23 allow: {}
24 visibility_config:
25 sampled_requests_enabled: yes
26 cloud_watch_metrics_enabled: yes
27 metric_name: fsd
28 statement:
29 byte_match_statement:
30 search_string: ansible.com
31 positional_constraint: CONTAINS
32 field_to_match:
33 single_header:
34 name: host
35 text_transformations:
36 - type: LOWERCASE
37 priority: 0
38 cloudwatch_metrics: yes
39 tags:
40 A: B
41 C: D
42 register: out
43 check_mode: yes
44
45 - name: check_mode verify create
46 assert:
47 that:
48 - out is changed
49
50 - name: create rule group
51 wafv2_rule_group:
52 name: "{{ rule_group_name }}"
53 state: present
54 description: hallo eins
55 scope: REGIONAL
56 capacity: 500
57 rules:
58 - name: eins
59 priority: 1
60 action:
61 allow: {}
62 visibility_config:
63 sampled_requests_enabled: yes
64 cloud_watch_metrics_enabled: yes
65 metric_name: fsd
66 statement:
67 byte_match_statement:
68 search_string: ansible.com
69 positional_constraint: CONTAINS
70 field_to_match:
71 single_header:
72 name: host
73 text_transformations:
74 - type: LOWERCASE
75 priority: 0
76 cloudwatch_metrics: yes
77 tags:
78 A: B
79 C: D
80 register: out
81
82 - name: verify create
83 assert:
84 that:
85 - out is changed
86
87 - name: rule group info
88 wafv2_rule_group_info:
89 name: "{{ rule_group_name }}"
90 scope: REGIONAL
91 register: out
92
93 - name: verify one rule
94 assert:
95 that:
96 - out.rules | count == 1
97
98 - name: immutable create rule group
99 wafv2_rule_group:
100 name: "{{ rule_group_name }}"
101 state: present
102 description: hallo eins
103 scope: REGIONAL
104 capacity: 500
105 rules:
106 - name: eins
107 priority: 1
108 action:
109 allow: {}
110 visibility_config:
111 sampled_requests_enabled: yes
112 cloud_watch_metrics_enabled: yes
113 metric_name: fsd
114 statement:
115 byte_match_statement:
116 search_string: ansible.com
117 positional_constraint: CONTAINS
118 field_to_match:
119 single_header:
120 name: host
121 text_transformations:
122 - type: LOWERCASE
123 priority: 0
124 cloudwatch_metrics: yes
125 tags:
126 A: B
127 C: D
128 register: out
129
130 - name: verify immutable create
131 assert:
132 that:
133 - out is not changed
134
135 - name: change description
136 wafv2_rule_group:
137 name: "{{ rule_group_name }}"
138 state: present
139 description: hallo eins zwei
140 scope: REGIONAL
141 capacity: 500
142 rules:
143 - name: eins
144 priority: 1
145 action:
146 allow: {}
147 visibility_config:
148 sampled_requests_enabled: yes
149 cloud_watch_metrics_enabled: yes
150 metric_name: fsd
151 statement:
152 byte_match_statement:
153 search_string: ansible.com
154 positional_constraint: CONTAINS
155 field_to_match:
156 single_header:
157 name: host
158 text_transformations:
159 - type: LOWERCASE
160 priority: 0
161 cloudwatch_metrics: yes
162 tags:
163 A: B
164 C: D
165 register: out
166
167 - name: verify change
168 assert:
169 that:
170 - out is changed
171
172 - name: iummutable change description
173 wafv2_rule_group:
174 name: "{{ rule_group_name }}"
175 state: present
176 description: hallo eins zwei
177 scope: REGIONAL
178 capacity: 500
179 rules:
180 - name: eins
181 priority: 1
182 action:
183 allow: {}
184 visibility_config:
185 sampled_requests_enabled: yes
186 cloud_watch_metrics_enabled: yes
187 metric_name: fsd
188 statement:
189 byte_match_statement:
190 search_string: ansible.com
191 positional_constraint: CONTAINS
192 field_to_match:
193 single_header:
194 name: host
195 text_transformations:
196 - type: LOWERCASE
197 priority: 0
198 cloudwatch_metrics: yes
199 tags:
200 A: B
201 C: D
202 register: out
203
204 - name: verify no change
205 assert:
206 that:
207 - out is not changed
208
209 - name: add rule
210 wafv2_rule_group:
211 name: "{{ rule_group_name }}"
212 state: present
213 description: hallo eins zwei
214 scope: REGIONAL
215 capacity: 500
216 rules:
217 - name: eins
218 priority: 1
219 action:
220 allow: {}
221 visibility_config:
222 sampled_requests_enabled: yes
223 cloud_watch_metrics_enabled: yes
224 metric_name: fsd
225 statement:
226 byte_match_statement:
227 search_string: ansible.com
228 positional_constraint: CONTAINS
229 field_to_match:
230 single_header:
231 name: host
232 text_transformations:
233 - type: LOWERCASE
234 priority: 0
235 - name: zwei
236 priority: 2
237 action:
238 block: {}
239 visibility_config:
240 sampled_requests_enabled: yes
241 cloud_watch_metrics_enabled: yes
242 metric_name: ddos
243 statement:
244 or_statement:
245 statements:
246 - byte_match_statement:
247 search_string: ansible.com
248 positional_constraint: CONTAINS
249 field_to_match:
250 single_header:
251 name: host
252 text_transformations:
253 - type: LOWERCASE
254 priority: 0
255 - xss_match_statement:
256 field_to_match:
257 body: {}
258 text_transformations:
259 - type: NONE
260 priority: 0
261 cloudwatch_metrics: yes
262 tags:
263 A: B
264 C: D
265 register: out
266
267 - name: verify change
268 assert:
269 that:
270 - out is changed
271
272 - name: immutable add rule
273 wafv2_rule_group:
274 name: "{{ rule_group_name }}"
275 state: present
276 description: hallo eins zwei
277 scope: REGIONAL
278 capacity: 500
279 rules:
280 - name: eins
281 priority: 1
282 action:
283 allow: {}
284 visibility_config:
285 sampled_requests_enabled: yes
286 cloud_watch_metrics_enabled: yes
287 metric_name: fsd
288 statement:
289 byte_match_statement:
290 search_string: ansible.com
291 positional_constraint: CONTAINS
292 field_to_match:
293 single_header:
294 name: host
295 text_transformations:
296 - type: LOWERCASE
297 priority: 0
298 - name: zwei
299 priority: 2
300 action:
301 block: {}
302 visibility_config:
303 sampled_requests_enabled: yes
304 cloud_watch_metrics_enabled: yes
305 metric_name: ddos
306 statement:
307 or_statement:
308 statements:
309 - byte_match_statement:
310 search_string: ansible.com
311 positional_constraint: CONTAINS
312 field_to_match:
313 single_header:
314 name: host
315 text_transformations:
316 - type: LOWERCASE
317 priority: 0
318 - xss_match_statement:
319 field_to_match:
320 body: {}
321 text_transformations:
322 - type: NONE
323 priority: 0
324 cloudwatch_metrics: yes
325 tags:
326 A: B
327 C: D
328 register: out
329
330 - name: verify no change
331 assert:
332 that:
333 - out is not changed
334
335 - name: change rule
336 wafv2_rule_group:
337 name: "{{ rule_group_name }}"
338 state: present
339 description: hallo eins zwei
340 scope: REGIONAL
341 capacity: 500
342 rules:
343 - name: eins
344 priority: 1
345 action:
346 allow: {}
347 visibility_config:
348 sampled_requests_enabled: yes
349 cloud_watch_metrics_enabled: yes
350 metric_name: fsd
351 statement:
352 byte_match_statement:
353 search_string: ansible.com
354 positional_constraint: CONTAINS
355 field_to_match:
356 single_header:
357 name: host
358 text_transformations:
359 - type: LOWERCASE
360 priority: 0
361 - name: zwei
362 priority: 3
363 action:
364 block: {}
365 visibility_config:
366 sampled_requests_enabled: yes
367 cloud_watch_metrics_enabled: yes
368 metric_name: ddos
369 statement:
370 or_statement:
371 statements:
372 - byte_match_statement:
373 search_string: ansible.com
374 positional_constraint: CONTAINS
375 field_to_match:
376 single_header:
377 name: host
378 text_transformations:
379 - type: LOWERCASE
380 priority: 0
381 - xss_match_statement:
382 field_to_match:
383 body: {}
384 text_transformations:
385 - type: NONE
386 priority: 0
387 cloudwatch_metrics: yes
388 tags:
389 A: B
390 C: D
391 register: out
392
393 - name: verify change
394 assert:
395 that:
396 - out is changed
397
398 - name: immutable change rule
399 wafv2_rule_group:
400 name: "{{ rule_group_name }}"
401 state: present
402 description: hallo eins zwei
403 scope: REGIONAL
404 capacity: 500
405 rules:
406 - name: eins
407 priority: 1
408 action:
409 allow: {}
410 visibility_config:
411 sampled_requests_enabled: yes
412 cloud_watch_metrics_enabled: yes
413 metric_name: fsd
414 statement:
415 byte_match_statement:
416 search_string: ansible.com
417 positional_constraint: CONTAINS
418 field_to_match:
419 single_header:
420 name: host
421 text_transformations:
422 - type: LOWERCASE
423 priority: 0
424 - name: zwei
425 priority: 3
426 action:
427 block: {}
428 visibility_config:
429 sampled_requests_enabled: yes
430 cloud_watch_metrics_enabled: yes
431 metric_name: ddos
432 statement:
433 or_statement:
434 statements:
435 - byte_match_statement:
436 search_string: ansible.com
437 positional_constraint: CONTAINS
438 field_to_match:
439 single_header:
440 name: host
441 text_transformations:
442 - type: LOWERCASE
443 priority: 0
444 - xss_match_statement:
445 field_to_match:
446 body: {}
447 text_transformations:
448 - type: NONE
449 priority: 0
450 cloudwatch_metrics: yes
451 tags:
452 A: B
453 C: D
454 register: out
455
456 - name: verify no change
457 assert:
458 that:
459 - out is not changed
460
461 - name: change rule again
462 wafv2_rule_group:
463 name: "{{ rule_group_name }}"
464 state: present
465 description: hallo eins zwei
466 scope: REGIONAL
467 capacity: 500
468 rules:
469 - name: zwei
470 priority: 1
471 action:
472 block: {}
473 visibility_config:
474 sampled_requests_enabled: yes
475 cloud_watch_metrics_enabled: yes
476 metric_name: ddos
477 statement:
478 or_statement:
479 statements:
480 - byte_match_statement:
481 search_string: ansible.com
482 positional_constraint: CONTAINS
483 field_to_match:
484 single_header:
485 name: host
486 text_transformations:
487 - type: LOWERCASE
488 priority: 0
489 - xss_match_statement:
490 field_to_match:
491 body: {}
492 text_transformations:
493 - type: NONE
494 priority: 0
495 - name: eins
496 priority: 2
497 action:
498 allow: {}
499 visibility_config:
500 sampled_requests_enabled: yes
501 cloud_watch_metrics_enabled: yes
502 metric_name: fsd
503 statement:
504 byte_match_statement:
505 search_string: ansible.com
506 positional_constraint: CONTAINS
507 field_to_match:
508 single_header:
509 name: host
510 text_transformations:
511 - type: LOWERCASE
512 priority: 0
513 cloudwatch_metrics: yes
514 tags:
515 A: B
516 C: D
517 register: out
518
519 - name: verify change
520 assert:
521 that:
522 - out is changed
523
524 - name: add one rule
525 wafv2_rule_group:
526 name: "{{ rule_group_name }}"
527 state: present
528 description: hallo eins zwei
529 scope: REGIONAL
530 capacity: 500
531 purge_rules: no
532 rules:
533 - name: allow-admin-svg
534 priority: 3
535 action:
536 allow: {}
537 visibility_config:
538 sampled_requests_enabled: yes
539 cloud_watch_metrics_enabled: yes
540 metric_name: allow-admin-svg
541 statement:
542 byte_match_statement:
543 search_string: admin.svg
544 positional_constraint: CONTAINS
545 field_to_match:
546 uri_path: {}
547 text_transformations:
548 - type: LOWERCASE
549 priority: 0
550 cloudwatch_metrics: yes
551 tags:
552 A: B
553 C: D
554 register: out
555
556 - name: verify change
557 assert:
558 that:
559 - out is changed
560
561 - name: rule group info
562 wafv2_rule_group_info:
563 name: "{{ rule_group_name }}"
564 scope: REGIONAL
565 register: out
566
567 - name: verify create
568 assert:
569 that:
570 - out.rules | count == 3
571
572 - name: immutable add one rule
573 wafv2_rule_group:
574 name: "{{ rule_group_name }}"
575 state: present
576 description: hallo eins zwei
577 scope: REGIONAL
578 capacity: 500
579 purge_rules: no
580 rules:
581 - name: allow-admin-svg
582 priority: 3
583 action:
584 allow: {}
585 visibility_config:
586 sampled_requests_enabled: yes
587 cloud_watch_metrics_enabled: yes
588 metric_name: allow-admin-svg
589 statement:
590 byte_match_statement:
591 search_string: admin.svg
592 positional_constraint: CONTAINS
593 field_to_match:
594 uri_path: {}
595 text_transformations:
596 - type: LOWERCASE
597 priority: 0
598 cloudwatch_metrics: yes
599 tags:
600 A: B
601 C: D
602 register: out
603
604 - name: verify no change
605 assert:
606 that:
607 - out is not changed
608
609 - name: purge rules
610 wafv2_rule_group:
611 name: "{{ rule_group_name }}"
612 state: present
613 description: hallo eins zwei
614 scope: REGIONAL
615 capacity: 500
616 purge_rules: yes
617 rules:
618 - name: allow-admin-svg
619 priority: 3
620 action:
621 allow: {}
622 visibility_config:
623 sampled_requests_enabled: yes
624 cloud_watch_metrics_enabled: yes
625 metric_name: allow-admin-svg
626 statement:
627 byte_match_statement:
628 search_string: admin.svg
629 positional_constraint: CONTAINS
630 field_to_match:
631 uri_path: {}
632 text_transformations:
633 - type: LOWERCASE
634 priority: 0
635 cloudwatch_metrics: yes
636 tags:
637 A: B
638 C: D
639 register: out
640
641 - name: verify change
642 assert:
643 that:
644 - out is changed
645
646 - name: absent one rule rules
647 wafv2_rule_group:
648 name: "{{ rule_group_name }}"
649 state: absent
650 description: hallo eins zwei
651 scope: REGIONAL
652 rules:
653 - name: allow-admin-svg
654 priority: 3
655 action:
656 allow: {}
657 visibility_config:
658 sampled_requests_enabled: yes
659 cloud_watch_metrics_enabled: yes
660 metric_name: allow-admin-svg
661 statement:
662 byte_match_statement:
663 search_string: admin.svg
664 positional_constraint: CONTAINS
665 field_to_match:
666 uri_path: {}
667 text_transformations:
668 - type: LOWERCASE
669 priority: 0
670 register: out
671
672 - name: verify change
673 assert:
674 that:
675 - out is changed
676
677 - name: rule group info
678 wafv2_rule_group_info:
679 name: "{{ rule_group_name }}"
680 scope: REGIONAL
681 register: out
682
683 - name: verify change
684 assert:
685 that:
686 - out.rules | count == 0
687
688 - include_tasks: 'tagging.yml'
689 - include_tasks: 'description.yml'
690
691 ##############################
692 # test delete wafv2 resources
693 ##############################
694 - name: remove rule group
695 wafv2_rule_group:
696 name: "{{ rule_group_name }}"
697 state: absent
698 scope: REGIONAL
699 register: out
700
701 - name: verify change
702 assert:
703 that:
704 - out is changed
705
706 - name: immutable remove rule group
707 wafv2_rule_group:
708 name: "{{ rule_group_name }}"
709 state: absent
710 scope: REGIONAL
711 register: out
712
713 - name: verify no change
714 assert:
715 that:
716 - out is not changed
717
718 always:
719 ###################################
720 # always delete wafv2 components
721 ###################################
722
723 - name: take care rule group is removed
724 wafv2_rule_group:
725 name: "{{ rule_group_name }}"
726 state: absent
727 scope: REGIONAL
728 ignore_errors: true