|
1 | 1 | --- |
2 | 2 | - name: Add icinga host downtimes |
| 3 | + when: icinga_downtime_host_downtime | bool |
3 | 4 | ansible.builtin.uri: |
4 | | - url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Host" |
5 | | - url_username: "{{ icinga_api_user }}" |
6 | | - url_password: "{{ icinga_api_password }}" |
| 5 | + url: "{{ icinga_downtime_icinga_api_uri }}:{{ icinga_downtime_icinga_api_port }}/v1/actions/schedule-downtime?type=Host" |
| 6 | + url_username: "{{ icinga_downtime_icinga_api_user }}" |
| 7 | + url_password: "{{ icinga_downtime_icinga_api_password }}" |
7 | 8 | validate_certs: true |
8 | 9 | method: POST |
9 | 10 | status_code: 200 |
|
13 | 14 | body_format: json |
14 | 15 | body: '{ |
15 | 16 | "filter": "host.name==\"{{ item }}\"", |
16 | | - "author": "{{ author }}", |
17 | | - "comment": "{{ comment }}", |
18 | | - "start_time": "{{ start_time_now }}", |
19 | | - "end_time": "{{ end_time }}", |
| 17 | + "author": "{{ icinga_downtime_author }}", |
| 18 | + "comment": "{{ icinga_downtime_comment }}", |
| 19 | + "start_time": "{{ icinga_downtime_start_time_now }}", |
| 20 | + "end_time": "{{ icinga_downtime_end_time }}", |
20 | 21 | "pretty": true, |
21 | 22 | "fixed": true, |
22 | 23 | }' |
23 | 24 | loop: |
24 | | - - "{{ icinga_host_filter }}" |
25 | | - when: |
26 | | - - host_downtime | bool |
| 25 | + - "{{ icinga_downtime_host_filter }}" |
27 | 26 |
|
28 | 27 | - name: Add icinga service downtimes |
| 28 | + when: |
| 29 | + - icinga_downtime_service_downtime | bool |
| 30 | + - icinga_downtime_service_filter == '' |
29 | 31 | ansible.builtin.uri: |
30 | | - url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Service" |
31 | | - url_username: "{{ icinga_api_user }}" |
32 | | - url_password: "{{ icinga_api_password }}" |
| 32 | + url: "{{ icinga_downtime_icinga_api_uri }}:{{ icinga_downtime_icinga_api_port }}/v1/actions/schedule-downtime?type=Service" |
| 33 | + url_username: "{{ icinga_downtime_icinga_api_user }}" |
| 34 | + url_password: "{{ icinga_downtime_icinga_api_password }}" |
33 | 35 | validate_certs: true |
34 | 36 | method: POST |
35 | 37 | status_code: 200 |
|
39 | 41 | body_format: json |
40 | 42 | body: '{ |
41 | 43 | "filter": "host.name==\"{{ item }}\"", |
42 | | - "author": "{{ author }}", |
43 | | - "comment": "{{ comment }}", |
44 | | - "start_time": {{ start_time_now }}, |
45 | | - "end_time": {{ end_time }}, |
| 44 | + "author": "{{ icinga_downtime_author }}", |
| 45 | + "comment": "{{ icinga_downtime_comment }}", |
| 46 | + "start_time": {{ icinga_downtime_start_time_now }}, |
| 47 | + "end_time": {{ icinga_downtime_end_time }}, |
46 | 48 | "pretty": true, |
47 | 49 | "fixed": true, |
48 | 50 | }' |
49 | 51 | delegate_to: localhost |
50 | 52 | loop: |
51 | | - - "{{ icinga_host_filter }}" |
52 | | - when: |
53 | | - - service_downtime | bool |
54 | | - - service_filter == '' |
| 53 | + - "{{ icinga_downtime_host_filter }}" |
55 | 54 |
|
56 | 55 | - name: Add icinga single service downtimes |
| 56 | + when: |
| 57 | + - icinga_downtime_single_service_downtime | bool |
| 58 | + - icinga_downtime_service_filter != '' |
57 | 59 | ansible.builtin.uri: |
58 | | - url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Service" |
59 | | - url_username: "{{ icinga_api_user }}" |
60 | | - url_password: "{{ icinga_api_password }}" |
| 60 | + url: "{{ icinga_downtime_icinga_api_uri }}:{{ icinga_downtime_icinga_api_port }}/v1/actions/schedule-downtime?type=Service" |
| 61 | + url_username: "{{ icinga_downtime_icinga_api_user }}" |
| 62 | + url_password: "{{ icinga_downtime_icinga_api_password }}" |
61 | 63 | validate_certs: true |
62 | 64 | method: POST |
63 | 65 | status_code: 200 |
|
66 | 68 | Accept: application/json |
67 | 69 | body_format: json |
68 | 70 | body: '{ |
69 | | - "filter": "host.name==\"{{ item }}\" && match(\"*{{ service_filter }}*\",service.name)", |
70 | | - "author": "{{ author }}", |
71 | | - "comment": "{{ comment }}", |
72 | | - "start_time": {{ start_time_now }}, |
73 | | - "end_time": {{ end_time }}, |
| 71 | + "filter": "host.name==\"{{ item }}\" && match("*{{ icinga_downtime_service_filter }}*",service.name)", |
| 72 | + "author": "{{ icinga_downtime_author }}", |
| 73 | + "comment": "{{ icinga_downtime_comment }}", |
| 74 | + "start_time": {{ icinga_downtime_start_time_now }}, |
| 75 | + "end_time": {{ icinga_downtime_end_time }}, |
74 | 76 | "pretty": true, |
75 | 77 | "fixed": true, |
76 | 78 | }' |
77 | 79 | delegate_to: localhost |
78 | 80 | loop: |
79 | | - - "{{ icinga_host_filter }}" |
80 | | - when: |
81 | | - - single_service_downtime | bool |
82 | | - - service_filter != '' |
| 81 | + - "{{ icinga_downtime_host_filter }}" |
0 commit comments