-
Notifications
You must be signed in to change notification settings - Fork 56
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] idempotency of rule fails on datasource_programs ruleset #552
Comments
This is related to #186. You can try to add more conditions to ensure idempotency. We are aware, that the current state is not great, but it is out of our hands. We can only provide viable workarounds. Try this: - name: add ssh rule
checkmk.general.rule:
ruleset: datasource_programs
rule:
location:
folder: "/"
conditions:
host_labels: []
service_labels: []
host_tags:
- key: ssh
operator: is
value: ssh_secure
properties:
description: ssh datasource for ssh_secure host tags
value_raw: "'ssh -T root@$HOSTNAME$'"
state: present |
ok, i'll try, but i'll be going on holiday for a week, so it'll have to wait a bit :-) |
I added host_labels and service_labels , but sadly, that didn't fix the issue; similar issues with special_agents:vsphere and snmp_communities should i use more conditions to try and fix this, or does it not work because the labels are empty? maybe i should just delete the rules.mk file and start over every time? but i'd rather not do that... |
it seems adding disabled: false may solve the issues... i don't get why this and the labels cannot have default values? but it also does not complain if these are not added... |
So, i have it(idempotency workaround) working for the "datasource_programs" rule, but not for snmp_communities and special_agents:vsphere , but the only difference really is the rule and that i'm using host_name instead of host_tags? : - name: add ssh rule
checkmk.general.rule:
ruleset: datasource_programs
rule:
location:
folder: "/"
conditions:
host_labels: []
service_labels: []
host_tags:
- key: ssh
operator: is
value: ssh_secure
properties:
comment: "Ansible managed"
description: ssh datasource for ssh_secure host tags
disabled: false
value_raw: "'ssh -T root@$HOSTNAME$'"
state: present
- name: Add SNMP rule
checkmk.general.rule:
ruleset: snmp_communities
rule:
location:
folder: "/"
conditions:
host_labels: []
service_labels: []
host_tags: []
host_name:
operator: one_of
match_on:
- "{{ host.name }}"
properties:
comment: "Ansible managed"
description: password for snmp {{ host.name }}
disabled: false
value_raw: "('{{ host.snmp }}')"
state: present
when: host.snmp is defined
- name: Add ESX rule
checkmk.general.rule:
ruleset: special_agents:vsphere
rule:
location:
folder: "/"
conditions:
host_labels: []
service_labels: []
host_tags: []
host_name:
operator: one_of
match_on:
- "{{ host.name }}"
properties:
comment: "Ansible managed"
description: password for ESX {{ host.name }}
disabled: false
value_raw: "{ 'direct': True, 'infos': ['hostsystem', 'virtualmachine', 'datastore', 'counters'], 'secret': '{{ host.esx }}', 'skip_placeholder_vms': True, 'spaces': 'underscore', 'use_pysphere': False, 'user': 'root', 'ssl': False, 'snapshots_on_host': False}"
state: present
when: host.esx is defined |
@alien999999999 as has already been explained in other issues, this is a general problem and neither specific to distinct rule sets, nor something we can quickly fix. Hence, I will close this issue and ask you to review the initially linked issue and maybe refer to the forum to exchange ideas and workarounds. Thank you for your understanding. |
I reread the initially linked issue and contrary to it's title (and original issue) it did end up being about this. It seems to me the workarounds for idempotency on rules (because checkmk code is not great about this atm) work for some rulesets, but some rulesets have different requirements for idempotency; or just plainly not work... I think the only real way to ensure idempotency on rules is to redesign this part of checkmk; start by adding a unique id; it may at least enable some easier idempotency workarounds |
We are actually currently reworking the |
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
Executing this rule repeatedly gets you an extra rule every time
Component Name
Component Name: rule
Ansible Version
Checkmk Version and Edition
Checkmk Raw Edition 2.2.0p21
Collection Version
$ ansible-galaxy collection list
To Reproduce
Steps to reproduce the behavior:
Expected behavior
ok [checkmk]
Actual behavior
changed [checkmk]
Minimum reproduction example
Additional context
The text was updated successfully, but these errors were encountered: