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] value_raw is translated wrongly while creating a rule with checkmk.general.rule: #523

Closed
Mik3yZ opened this issue Jan 3, 2024 · 4 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists module:rule This affects the rule module

Comments

@Mik3yZ
Copy link
Contributor

Mik3yZ commented Jan 3, 2024

Describe the bug
We are creating rules via a loop, with a vars file. The code for creating the rule:

- name: "Create global rule for in main folder"
  delegate_to: localhost
  checkmk.general.rule:
    automation_secret: "{{ automation_secret }}"
    automation_user: "{{ automation_user }}"
    rule:
      conditions: "{{ item.rule.conditions }}"
      properties:
        description: "{{ item.rule.properties.description }}"
        comment: "{{ item.rule.properties.comment | default() }}"
        disabled: "{{ item.rule.properties.disabled | default(False) }}"
        documentation_url: "https://sharepoint.website/onenote_notebook/page_something"
      value_raw: "{{ item.rule.value_raw }}"
      location: "{{ item.rule.location }}"
    ruleset: "{{ item.ruleset }}"
    server_url: "{{ master_site_baseurl }}"
    site: "{{ master_site }}"
  loop: "{{ rulesets | flatten(levels=1) }}"
  loop_control:
    label: "{{ item.ruleset }} [{{ item.rule.properties.description | default() }}]"

The item from the loop that fails:

- - rule:
      conditions:
        host_labels: []
        host_tags:
        - key: g_t_discovery
          operator: is
          value: g_t_discovery_enabled_ssl_auto
        - key: g_t_host_check_command
          operator: none_of
          value:
          - g_t_hcc_ping
          - g_t_hcc_alwaysup
          - g_t_hcc_always_offline
        service_labels: []
      location:
        folder: /
      properties:
        description: Automatically activate SSL certficate changes (remove/add)
      value_raw: "{'check_interval': 120.0, 'inventory_rediscovery': {'activation': True, 'excluded_time': [], 'group_time': 300, 'mode': 2, 'service_filters': ('combined', {'service_whitelist': ['^SSL.*']})}, 'severity_new_host_label': 1, 'severity
_unmonitored': 1, 'severity_vanished': 0}"
    ruleset: periodic_discovery

When we run this with -vvv we can see the issue happening, value_raw becomes:

"value_raw": "{'check_interval': 120.0, 'inventory_rediscovery': {'activation': True, 'excluded_time': [], 'group_time': 300, 'mode': 2, 'service_filters': ['combined', {'service_whitelist': ['^SSL.*']}]}, 'severity_new_host_label': 1, 'severity_unmonitored': 1, 'severity_vanished': 0}"

The issue is actually with the ( and ) in the service_filters. They get changed to [ and ]

Component Name
Component Name: rule

Ansible Version

$ ansible --version
ansible [core 2.14.13]
  config file = /home/user/repos/CheckMK/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/venvs/ansible-checkmk/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/venvs/ansible-checkmk/bin/ansible
  python version = 3.9.16 (main, May 29 2023, 00:00:00) [GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] (/home/user/venvs/ansible-checkmk/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Checkmk Version and Edition

Checkmk Enterprise Edition 2.2.0p16

Collection Version

$ ansible-galaxy collection list
...
Collection             Version
---------------------- -------
ansible.posix          1.5.4  
brocade.fos            1.3.3  
checkmk.general        4.0.0  
community.general      7.0.1  
community.vmware       3.3.0  
ibm.power_aix          1.7.2  
ibm.power_hmc          1.8.1  
ibm.power_vios         1.3.0  
ibm.storage_virtualize 2.1.0  
kubernetes.core        2.3.2  
seancallaway.rancher   0.2.1  
tribe29.checkmk        0.22.0

To Reproduce
Steps to reproduce the behavior kind of described in the description above.

Expected behavior
The rule gets created, the ( and ) don't get translated / replaced in the value_raw.

Actual behavior
Rule creation fails, the ( and ) get translated / replaced in the value_raw.

@Mik3yZ Mik3yZ added the bug Something isn't working label Jan 3, 2024
@github-actions github-actions bot added the module:rule This affects the rule module label Jan 3, 2024
@Mik3yZ
Copy link
Contributor Author

Mik3yZ commented Jan 3, 2024

This issue seems somewhat related to this issue/comment by @clagio in #186 (comment)_

@robin-checkmk
Copy link
Member

Hi @Mik3yZ and thanks for taking the time and effort to report this issue properly.
However, I think this is not only related to #186 but the discussion covers it all.
May I ask you to provide any additional details or information, that you feel is missing there?
I would close this as a duplicate then, to avoid cluttering the issue list.

@Mik3yZ
Copy link
Contributor Author

Mik3yZ commented Jan 3, 2024

Hi @robin-checkmk,

i'll continue the discussion in the other thread then. My main concern was there are way more challanges involved in that issue, as only the translation/replacement of certain characters in value_raw. but i do agree to continue there.

@robin-checkmk robin-checkmk added the duplicate This issue or pull request already exists label Jan 3, 2024
@robin-checkmk
Copy link
Member

Closing this as a duplicate of #186.

@robin-checkmk robin-checkmk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists module:rule This affects the rule module
Projects
None yet
Development

No branches or pull requests

2 participants