tribe29 / tribe29.checkmk / 0.23.0 / module / rule Manage rules in Checkmk. | "added in version" 0.10.0 of tribe29.checkmk" Authors: diademiemi (@diademiemi), Geoffroy Stévenne (@geof77)tribe29.checkmk.rule (0.23.0) — module
Install with ansible-galaxy collection install tribe29.checkmk:==0.23.0
collections: - name: tribe29.checkmk version: 0.23.0
Manage rules within Checkmk. Importing rules from the output of the Checkmk API.
Make sure these were exported with Checkmk 2.1.0p10 or above. See https://checkmk.com/werk/14670 for more information.
# Create a rule in checkgroup_parameters:memory_percentage_used # at the top of the main folder. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." tribe29.checkmk.rule: server_url: "http://localhost/" site: "my_site" automation_user: "automation" automation_secret: "$SECRET" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { "host_labels": [], "host_name": { "match_on": [ "test1.tld" ], "operator": "one_of" }, "host_tags": [], "service_labels": [] } properties: { "comment": "Warning at 80%\nCritical at 90%\n", "description": "Allow higher memory usage", "disabled": false, "documentation_url": "https://github.com/Checkmk/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/rules.py" } folder: "/" value_raw: "{'levels': (80.0, 90.0)}" location: folder: "/" position: "top" state: "present" register: response
- name: Show the ID of the new rule debug: msg: "RULE ID : {{ response.id }}"
# Create another rule in checkgroup_parameters:memory_percentage_used # and put it after the rule created above. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." tribe29.checkmk.rule: server_url: "http://localhost/" site: "my_site" automation_user: "automation" automation_secret: "$SECRET" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { "host_labels": [], "host_name": { "match_on": [ "test2.tld" ], "operator": "one_of" }, "host_tags": [], "service_labels": [] } properties: { "comment": "Warning at 85%\nCritical at 99%\n", "description": "Allow even higher memory usage", "disabled": false, "documentation_url": "https://github.com/Checkmk/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/rules.py" } value_raw: "{'levels': (85.0, 99.0)}" location: position: "after" rule_id: "{{ response.id }}" state: "present"
# Delete the first rule. - name: "Delete a rule." tribe29.checkmk.rule: server_url: "http://localhost/" site: "my_site" automation_user: "automation" automation_secret: "$SECRET" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { "host_labels": [], "host_name": { "match_on": [ "test1.tld" ], "operator": "one_of" }, "host_tags": [], "service_labels": [] } properties: { "comment": "Warning at 80%\nCritical at 90%\n", "description": "Allow higher memory usage", "disabled": false, "documentation_url": "https://github.com/Checkmk/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/rules.py" } value_raw: "{'levels': (80.0, 90.0)}" state: "absent"
rule: description: Definition of the rule as returned by the Checkmk API. required: true suboptions: conditions: description: Conditions of the rule. type: dict folder: description: - Folder of the rule. - Deprecated, use I(location) instead. - Mutually exclusive with I(location). type: str location: description: - Location of the rule within a folder. - By default rules are created at the bottom of the "/" folder. - Mutually exclusive with I(folder). suboptions: folder: default: / description: - Folder of the rule. - Required when I(position) is C(top) or C(bottom). - Required when I(state=absent). - Mutually exclusive with I(rule_id). type: str position: choices: - top - bottom - before - after default: bottom description: - Position of the rule in the folder. - Has no effect when I(state=absent). type: str rule_id: description: - Put the rule C(before) or C(after) this rule_id. - Required when I(position) is C(before) or C(after). - Mutually exclusive with I(folder). type: str type: dict properties: description: Properties of the rule. type: dict value_raw: description: Rule values as exported from the web interface. type: str type: dict site: description: The site you want to connect to. required: true type: str state: choices: - present - absent default: present description: State of the rule. type: str ruleset: description: Name of the ruleset to manage. required: true type: str server_url: description: The base url of your Checkmk server. required: true type: str validate_certs: default: true description: Whether to validate the SSL certificate of the Checkmk server. type: bool automation_user: description: The automation user you want to use. It has to be an 'Automation' user, not a normal one. required: true type: str automation_secret: description: The secret to authenticate your automation user. required: true type: str
id: description: The ID of the rule. returned: when the rule is created or when it already exists sample: 1f97bc43-52dc-4f1a-ab7b-c2e9553958ab type: str msg: description: The output message that the module generates. Contains the API status details in case of an error. returned: always sample: Rule created. type: str