Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] checkmk.general.rule not Idempotent #498

Closed
fabriceverkor opened this issue Dec 15, 2023 · 2 comments
Closed

[BUG] checkmk.general.rule not Idempotent #498

fabriceverkor opened this issue Dec 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working module:rule This affects the rule module

Comments

@fabriceverkor
Copy link

Verify first that your issue is not already reported here.
Where possible also test if the latest release and main branch are affected too.
Complete all sections as described!

Describe the bug
checkmk.general.rule always recreate the same rule

Component Name
Component Name: rule

Ansible Version
ansible [core 2.12.10]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /etc/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
jinja version = 2.11.3
libyaml = True

Checkmk Version and Edition
2.2.0p14 Raw

Collection Version
ansible.netcommon 3.1.1
ansible.posix 1.5.2
ansible.utils 2.6.1
ansible.windows 1.7.3
azure.azcollection 1.16.0
checkmk.general 4.0.1
community.general 5.7.0
community.grafana 1.5.2
community.postgresql 2.2.0
community.windows 1.7.0
fahcsim.grafana_stack 1.2.1
fortinet.fortios 2.1.2
nutanix.ncp 1.8.0
veeamhub.veeam 1.3.

To Reproduce
Steps to reproduce the behavior:
ansible-playbook rule.yml

Expected behavior
NOTES:
* To achieve idempotency, this module is comparing the specified rule with the already existing rules based on
conditions, folder, value_raw and enabled/disabled.

Actual behavior
Multiple identical rules are created at each run.

Minimum reproduction example

  • name: Create Rule to populate Hostgroup with Folder members
    checkmk.general.rule:
    server_url: "{{ checkmk_url }}"
    site: "{{ site }}"
    automation_user: automation
    automation_secret: "{{ VAULT_CHECKMK_AUTOMATION_SECRET }}"
    ruleset: "host_groups"
    rule:
    properties:
    description: "VmwareServers"
    location:
    folder: "/VmwareServers"
    value_raw: "'VmwareServers'"
@fabriceverkor fabriceverkor added the bug Something isn't working label Dec 15, 2023
@github-actions github-actions bot added the module:rule This affects the rule module label Dec 15, 2023
@robin-checkmk
Copy link
Member

Please read #186 carefully for a background on this topic.

My experience shows, that if you create rules like the following, with all the possible conditions, then idempotency is quite decent.

  - ruleset: "checkgroup_parameters:filesystem"
    rule:
      location:
        folder: "/"
        position: "bottom"
      properties: {
        "comment": "{{ ansible_date_time.iso8601 }} Set by Ansible",
        "disabled": false
      }
      value_raw: "{'magic': 0.8}"
      "conditions": {
        "host_labels": [],
        "service_labels": [],
        "host_tags": [],
      }

@fabriceverkor
Copy link
Author

fabriceverkor commented Dec 15, 2023

I changed the code see bold part below. And it works now.
Thx.

checkmk.general.rule:
server_url: "{{ checkmk_url }}"
site: "{{ site }}"
automation_user: automation
automation_secret: "{{ VAULT_CHECKMK_AUTOMATION_SECRET }}"
ruleset: "host_groups"
rule:`
properties:
description: "VmwareServers"
disabled: false
location:
folder: "/VmwareServers"
conditions:
host_labels: []
service_labels: []
host_tags: []

value_raw: "'VmwareServers'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:rule This affects the rule module
Projects
None yet
Development

No branches or pull requests

2 participants