Checkmk / ansible-collection-checkmk.general

The official Checkmk Ansible collection - brought to you by the Checkmk company.
https://galaxy.ansible.com/checkmk/general
GNU General Public License v3.0
121 stars 56 forks source link

[BUG] Downtime cannot be changed #672

Open mayrstefan opened 1 week ago

mayrstefan commented 1 week ago

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
robin-checkmk commented 1 week ago

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.