ansible-collection-checkmk.general icon indicating copy to clipboard operation
ansible-collection-checkmk.general copied to clipboard

[FEED] Downtime cannot be changed

Open mayrstefan opened this issue 1 year ago • 4 comments

Describe the bug When patching servers with ansible we set a quite long downtime in Checkmk. After the patching is done we would like to reduce the downtime window instead of removing it for auditing purpose.

Trying to do this with the ansible collection does not work: setting the endtime via the downtime module does not change the downtime.

Component Name Component Name: downtime

Ansible Version This is from a test wsl installation in Ubuntu 22.04. The issue is also present for different ansible versions

$ ansible --version
ansible 2.10.8
  config file = None
  configured module search path = ['/home/stefan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]

Checkmk Version and Edition

Checkmk Raw Edition 2.3.0p18

Collection Version

checkmk.general:5.3.0

To Reproduce Steps to reproduce the behavior:

  1. Set downtime
  2. Try to change end_after or end_time
  3. See that downtime has not changed

Expected behavior When a new endtime is set it should be changed

Actual behavior Nothing changes

Minimum reproduction example

---
- name: "Test Downtimes"
  hosts: all
  connection: local
  gather_facts: false
  vars:
    checkmk_var_server_url: "http://localhost:8080"
    checkmk_var_automation_user: "cmkadmin"
    checkmk_var_automation_secret: "..."
    mysite: "cmk"
  tasks:
    - name: "Set Downtime"
      checkmk.general.downtime:
        comment: "Downtime to be changed"
        server_url: "{{ checkmk_var_server_url }}"
        site: "{{ mysite }}"
        automation_user: "{{ checkmk_var_automation_user }}"
        automation_secret: "{{ checkmk_var_automation_secret }}"
        host_name: "{{ inventory_hostname }}"
        end_after:
          hours: 2

    - name: "Change Downtime"
      checkmk.general.downtime:
        comment: "Downtime to be changed"
        server_url: "{{ checkmk_var_server_url }}"
        site: "{{ mysite }}"
        automation_user: "{{ checkmk_var_automation_user }}"
        automation_secret: "{{ checkmk_var_automation_secret }}"
        host_name: "{{ inventory_hostname }}"
        end_after:
          minutes: 1

Running this playbook already shows the second task does nothing:

$ ansible-playbook -i 'demo.example.com,' test-downtimes.yml

PLAY [Test Downtimes] **************************************************************************************

TASK [Set Downtime] ****************************************************************************************
changed: [demo.example.com]

TASK [Change Downtime] *************************************************************************************
ok: [demo.example.com]

PLAY RECAP *************************************************************************************************
demo.example.com           : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

mayrstefan avatar Oct 13 '24 15:10 mayrstefan

Hi @mayrstefan and thanks for reporting this! I can reproduce the issue and we will look into it.

As a workaround, you could use flexible downtimes or delete and re-add the downtime.

robin-checkmk avatar Oct 16 '24 08:10 robin-checkmk

Hi @mayrstefan, the current downtime module doesn't support changing existing downtimes.

Implementing the possibility to change existing downtimes needs a lot of code change. As the code of this module is quite old, I decided to overhaul it in general and implement your feature request, then.

Until this happens, you can use the workaround described by Robin.

lgetwan avatar Oct 31 '24 10:10 lgetwan

This issue has been stale for 60 days. It will close in 7 days.

github-actions[bot] avatar Dec 31 '24 03:12 github-actions[bot]

I did a complete rework of the downtime module, but I need some more time to finish it.

lgetwan avatar Jan 07 '25 10:01 lgetwan

This issue has been stale for 60 days. It will close in 7 days.

github-actions[bot] avatar Mar 29 '25 03:03 github-actions[bot]

Any estimates when we will see the update downtime module?

mayrstefan avatar Apr 11 '25 17:04 mayrstefan

Since writing my above comment, I haven't found any time to continue my work here. :-( Hope I will be able to finish my work shortly before or after the conference.

lgetwan avatar Apr 14 '25 12:04 lgetwan

This issue has been stale for 60 days. It will close in 7 days.

github-actions[bot] avatar Jun 14 '25 03:06 github-actions[bot]

The conference was three weeks ago. We should keep this ticket alive.

mayrstefan avatar Jun 14 '25 06:06 mayrstefan

This issue has been stale for 60 days. It will close in 7 days.

github-actions[bot] avatar Aug 14 '25 03:08 github-actions[bot]

This issue has been stale for 60 days. It will close in 7 days.

github-actions[bot] avatar Oct 15 '25 03:10 github-actions[bot]