Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:Checkmk/ansible-collection-checkmk…
Browse files Browse the repository at this point in the history
….general into devel
  • Loading branch information
robin-checkmk committed Jul 12, 2024
2 parents b6ab009 + 2b26bd8 commit 4f8c6c6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/downtime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Downtime module - Downtimes are now correctly removed when only specifying a single service
6 changes: 5 additions & 1 deletion plugins/modules/downtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def _get_current_downtimes(module, base_url, headers):
)
]
else:
filters = ['{"op": "~", "left": "service_description", "right": "%s"}']
filters = [
'{"op": "~", "left": "service_description", "right": "%s"}'
% service_descriptions[0]
]
filters.append('{"op": "=", "left": "is_service", "right": "1"}')
else:
filters.append('{"op": "=", "left": "is_service", "right": "0"}')
Expand Down Expand Up @@ -356,6 +359,7 @@ def remove_downtime(module, base_url, headers):
else:
query_filters.append(
'{"op": "~", "left": "service_description", "right": "%s"}'
% service_descriptions[0]
)

if len(current_downtimes) == 0: # and comment is not None:
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/targets/downtime/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,35 @@
state: absent
loop: "{{ checkmk_hosts }}"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on single service."
downtime:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ outer_item.site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ item.name }}"
comment: Schedule downtime on single service
end_after:
minutes: 30
service_descriptions:
- "Check_MK"
loop: "{{ checkmk_hosts }}"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete downtime on single service."
downtime:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ outer_item.site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ item.name }}"
comment: Schedule downtime on single service
service_descriptions:
- "Check_MK"
state: absent
register: result
failed_when: result.changed == False
loop: "{{ checkmk_hosts }}"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts."
host:
server_url: "{{ checkmk_var_server_url }}"
Expand Down

0 comments on commit 4f8c6c6

Please sign in to comment.