From 6f39205d1afef3056493291c00d36afcd9331992 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Wed, 20 Dec 2023 11:12:30 +0100 Subject: [PATCH 01/49] The rule module has now a parameter rule_id that can be used to identify an existing rule. --- plugins/lookup/rules.py | 157 ++++++++++++++++++++++++++++++++++++++++ plugins/modules/rule.py | 79 ++++++++++++++------ 2 files changed, 212 insertions(+), 24 deletions(-) create mode 100644 plugins/lookup/rules.py diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py new file mode 100644 index 000000000..2b66acdf1 --- /dev/null +++ b/plugins/lookup/rules.py @@ -0,0 +1,157 @@ +# Copyright: (c) 2023, Lars Getwan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ + name: rules + author: Lars Getwan (@lgetwan) + version_added: "3.5.0" + short_description: List rules + description: + - Returns a list of Rules + options: + ruleset: + description: The ruleset name. + required: True + description_regex: + description: A regex to filter for certain descriptions. + required: False + default: "" + comment_regex: + description: A regex to filter for certain comment stings. + required: False + default: "" + server_url: + description: URL of the Checkmk server. + required: True + site: + description: Site name. + required: True + automation_user: + description: Automation user for the REST API access. + required: True + automation_secret: + description: Automation secret for the REST API access. + required: True + validate_certs: + description: Whether or not to validate TLS cerificates. + type: boolean + required: False + default: True +""" + +EXAMPLES = """ +- name: Get all rules of the ruleset host_groups + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + loop: "{{ + lookup('checkmk.general.rules', + ruleset='host_groups', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + loop_control: + label: "{{ item.id }}" + +- name: actice_checks:http rules that match a certain description AND comment + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + loop: "{{ + lookup('checkmk.general.rules', + ruleset='actice_checks:http', + description_regex='foo.*bar', + comment_regex='xmas-edition', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + loop_control: + label: "{{ item.id }}" +""" + +RETURN = """ + _list: + description: + - A list of all rules of a particular ruleset + type: list + elements: str +""" + +import json +import re + +from ansible.errors import AnsibleError +from ansible.plugins.lookup import LookupBase +from ansible_collections.checkmk.general.plugins.module_utils.lookup_api import ( + CheckMKLookupAPI, +) + + +class LookupModule(LookupBase): + def run(self, terms, variables, **kwargs): + regex_params = {} + self.set_options(var_options=variables, direct=kwargs) + ruleset = self.get_option("ruleset") + regex_params["description"] = self.get_option("description_regex") + regex_params["comment"] = self.get_option("comment_regex") + server_url = self.get_option("server_url") + site = self.get_option("site") + user = self.get_option("automation_user") + secret = self.get_option("automation_secret") + validate_certs = self.get_option("validate_certs") + + site_url = server_url + "/" + site + + api = CheckMKLookupAPI( + site_url=site_url, + user=user, + secret=secret, + validate_certs=validate_certs, + ) + + parameters = { + "ruleset_name": ruleset, + } + + response = json.loads(api.get("/domain-types/rule/collections/all", parameters)) + + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + rule_list = response.get("value") + + for what, regex in regex_params.items(): + try: + if regex: + rule_list = [ + r + for r in rule_list + if re.search( + regex, + r.get("extensions", {}).get("properties", {}).get(what, ""), + ) + ] + except re.error as e: + raise AnsibleError( + "Invalid regex for %s, pattern: %s, position: %s error: %s" + % (what, e.pattern, e.pos, e.msg) + ) + + return [rule_list] diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index aa7530f8c..1e28af9a0 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -67,6 +67,11 @@ properties: description: Properties of the rule. type: dict + rule_id: + description: + - If given, it will be C(the only condition) to identify the rule to work on. + - When there's no rule found with this id, the task will fail. + type: str value_raw: description: Rule values as exported from the web interface. type: str @@ -280,6 +285,25 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): module, url, module.jsonify(params), headers=headers, method="GET" ) + if info["status"] != 200: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], str(info)), + ) + + return json.loads(response.read().decode("utf-8")).get("value") + + +def show_rule(module, base_url, headers, rule_id): + api_endpoint = "/objects/rule/" + rule_id + + url = "%s%s" % (base_url, api_endpoint) + + response, info = fetch_url( + module, url, headers=headers, method="GET" + ) + if info["status"] != 200: exit_failed( module, @@ -291,8 +315,12 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): def get_existing_rule(module, base_url, headers, ruleset, rule): - # Get rules in ruleset - rules = get_rules_in_ruleset(module, base_url, headers, ruleset) + if rule.get("rule_id"): + # We already know whih rule to get + return rule.get("rule_id") + else: + # Get rules in ruleset + rules = get_rules_in_ruleset(module, base_url, headers, ruleset) (value_mod, exc) = safe_eval(rule["value_raw"], include_exceptions=True) if exc is not None: @@ -300,7 +328,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if rules is not None: # Loop through all rules - for r in rules.get("value"): + for r in rules: (value_api, exc) = safe_eval( r["extensions"]["value_raw"], include_exceptions=True ) @@ -314,7 +342,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): and value_api == value_mod ): # If they are the same, return the ID - return r + return r["id"] return None @@ -323,9 +351,9 @@ def create_rule(module, base_url, headers, ruleset, rule): api_endpoint = "/domain-types/rule/collections/all" changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: - return (e["id"], not changed) + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + if rule_id: + return (rule_id, not changed) if module.check_mode: return (None, changed) @@ -358,10 +386,11 @@ def create_rule(module, base_url, headers, ruleset, rule): def delete_rule(module, base_url, headers, ruleset, rule): changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + + if rule_id: if not module.check_mode: - delete_rule_by_id(module, base_url, headers, e["id"]) + delete_rule_by_id(module, base_url, headers, rule_id) return changed return not changed @@ -447,6 +476,7 @@ def run_module(): conditions=dict(type="dict"), properties=dict(type="dict"), value_raw=dict(type="str"), + rule_id=dict(type="str"), location=dict( type="dict", options=dict( @@ -495,23 +525,24 @@ def run_module(): # Get the variables ruleset = module.params.get("ruleset", "") - rule = module.params.get("rule", "") + rule = module.params.get("rule", {}) location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] - if rule.get("properties") is None or rule.get("properties") == "": - exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": - exit_failed(module, "Rule value_raw is required") - # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": - rule["conditions"] = { - "host_tags": [], - "host_labels": [], - "service_labels": [], - } + if rule.get("rule_id") is None or rule.get("rule_id") == "": + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] + if rule.get("properties") is None or rule.get("properties") == "": + exit_failed(module, "Rule properties are required") + if rule.get("value_raw") is None or rule.get("value_raw") == "": + exit_failed(module, "Rule value_raw is required") + # Default to all hosts if conditions arent given + if rule.get("conditions") is None or rule.get("conditions") == "": + rule["conditions"] = { + "host_tags": [], + "host_labels": [], + "service_labels": [], + } if module.params.get("state") == "absent": if location.get("rule_id") is not None: exit_failed(module, "rule_id in location is invalid with state=absent") From 134836a301782481bc3b366914558da388692b8c Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 9 Jan 2024 07:48:03 +0100 Subject: [PATCH 02/49] Ongoing development. --- plugins/modules/rule.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 1e28af9a0..885f3d091 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -317,7 +317,10 @@ def show_rule(module, base_url, headers, rule_id): def get_existing_rule(module, base_url, headers, ruleset, rule): if rule.get("rule_id"): # We already know whih rule to get - return rule.get("rule_id") + if module.params.get("state") == "absent": + # When deleting and we already know the ID, don't compare + return rule.get("rule_id") + rules = [ show_rule(module, base_url, headers, rule.get("rule_id")) ] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -529,9 +532,9 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] if rule.get("properties") is None or rule.get("properties") == "": exit_failed(module, "Rule properties are required") if rule.get("value_raw") is None or rule.get("value_raw") == "": From f23018754e2be31c773b0e80b43a8c3a7328361d Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:01:22 +0100 Subject: [PATCH 03/49] Now it's also possible to change existing rules based on a given rule_id. --- plugins/modules/rule.py | 65 +++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 885f3d091..f7f352d6a 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -387,6 +387,42 @@ def create_rule(module, base_url, headers, ruleset, rule): return (r["id"], changed) +def modify_rule(module, base_url, headers, ruleset, rule): + changed = True + rule_id = rule.get("rule_id") + + if not rule_id: + return not changed + + if module.check_mode: + return (None, changed) + + headers["If-Match"] = get_rule_etag(module, base_url, headers, rule_id) + + params = { + "properties": rule["properties"], + "value_raw": rule["value_raw"], + "conditions": rule["conditions"], + } + + api_endpoint = "/objects/rule/" + rule_id + url = base_url + api_endpoint + + info = fetch_url( + module, url, module.jsonify(params), headers=headers, method="PUT" + )[1] + #exit_failed(module, "###### INFO: %s" % str(info)) + + if info["status"] not in [200, 204]: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], info["body"]), + ) + + return changed + + def delete_rule(module, base_url, headers, ruleset, rule): changed = True rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) @@ -532,15 +568,15 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": + if not rule.get("folder"): rule["folder"] = location["folder"] - if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("properties") is None or rule.get("properties") == "": + if not rule.get("rule_id"): + if not rule.get("properties"): exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": + if not rule.get("value_raw"): exit_failed(module, "Rule value_raw is required") # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": + if rule.get("conditions"): rule["conditions"] = { "host_tags": [], "host_labels": [], @@ -559,13 +595,24 @@ def run_module(): exit_ok(module, "Rule does not exist") # If state is present, create the rule elif module.params.get("state") == "present": - (rule_id, created) = create_rule(module, base_url, headers, ruleset, rule) - if created: + action = None + if rule.get("rule_id"): + # Modify an existing rule + rule_id = rule.get("rule_id") + if modify_rule(module, base_url, headers, ruleset, rule): + action = "changed" + else: + # If no rule_id is mentioned, we check if our rule exists. If not, then create it. + (rule_id, changed) = create_rule(module, base_url, headers, ruleset, rule) + if changed: + action = "created" + + if action: # Move rule to specified location, if it's not default if location["position"] != "bottom" and not module.check_mode: move_rule(module, base_url, headers, rule_id, location) - exit_changed(module, "Rule created", rule_id) - exit_ok(module, "Rule already exists", rule_id) + exit_changed(module, "Rule %s" % action, rule_id) + exit_ok(module, "Rule already exists with equal settings", rule_id) # Fallback exit_failed(module, "Unknown error") From 48f34296229f224528669bf3cc6b75abe7eda07d Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Wed, 20 Dec 2023 11:12:30 +0100 Subject: [PATCH 04/49] The rule module has now a parameter rule_id that can be used to identify an existing rule. --- plugins/modules/rule.py | 79 ++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index aa7530f8c..1e28af9a0 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -67,6 +67,11 @@ properties: description: Properties of the rule. type: dict + rule_id: + description: + - If given, it will be C(the only condition) to identify the rule to work on. + - When there's no rule found with this id, the task will fail. + type: str value_raw: description: Rule values as exported from the web interface. type: str @@ -280,6 +285,25 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): module, url, module.jsonify(params), headers=headers, method="GET" ) + if info["status"] != 200: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], str(info)), + ) + + return json.loads(response.read().decode("utf-8")).get("value") + + +def show_rule(module, base_url, headers, rule_id): + api_endpoint = "/objects/rule/" + rule_id + + url = "%s%s" % (base_url, api_endpoint) + + response, info = fetch_url( + module, url, headers=headers, method="GET" + ) + if info["status"] != 200: exit_failed( module, @@ -291,8 +315,12 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): def get_existing_rule(module, base_url, headers, ruleset, rule): - # Get rules in ruleset - rules = get_rules_in_ruleset(module, base_url, headers, ruleset) + if rule.get("rule_id"): + # We already know whih rule to get + return rule.get("rule_id") + else: + # Get rules in ruleset + rules = get_rules_in_ruleset(module, base_url, headers, ruleset) (value_mod, exc) = safe_eval(rule["value_raw"], include_exceptions=True) if exc is not None: @@ -300,7 +328,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if rules is not None: # Loop through all rules - for r in rules.get("value"): + for r in rules: (value_api, exc) = safe_eval( r["extensions"]["value_raw"], include_exceptions=True ) @@ -314,7 +342,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): and value_api == value_mod ): # If they are the same, return the ID - return r + return r["id"] return None @@ -323,9 +351,9 @@ def create_rule(module, base_url, headers, ruleset, rule): api_endpoint = "/domain-types/rule/collections/all" changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: - return (e["id"], not changed) + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + if rule_id: + return (rule_id, not changed) if module.check_mode: return (None, changed) @@ -358,10 +386,11 @@ def create_rule(module, base_url, headers, ruleset, rule): def delete_rule(module, base_url, headers, ruleset, rule): changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + + if rule_id: if not module.check_mode: - delete_rule_by_id(module, base_url, headers, e["id"]) + delete_rule_by_id(module, base_url, headers, rule_id) return changed return not changed @@ -447,6 +476,7 @@ def run_module(): conditions=dict(type="dict"), properties=dict(type="dict"), value_raw=dict(type="str"), + rule_id=dict(type="str"), location=dict( type="dict", options=dict( @@ -495,23 +525,24 @@ def run_module(): # Get the variables ruleset = module.params.get("ruleset", "") - rule = module.params.get("rule", "") + rule = module.params.get("rule", {}) location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] - if rule.get("properties") is None or rule.get("properties") == "": - exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": - exit_failed(module, "Rule value_raw is required") - # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": - rule["conditions"] = { - "host_tags": [], - "host_labels": [], - "service_labels": [], - } + if rule.get("rule_id") is None or rule.get("rule_id") == "": + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] + if rule.get("properties") is None or rule.get("properties") == "": + exit_failed(module, "Rule properties are required") + if rule.get("value_raw") is None or rule.get("value_raw") == "": + exit_failed(module, "Rule value_raw is required") + # Default to all hosts if conditions arent given + if rule.get("conditions") is None or rule.get("conditions") == "": + rule["conditions"] = { + "host_tags": [], + "host_labels": [], + "service_labels": [], + } if module.params.get("state") == "absent": if location.get("rule_id") is not None: exit_failed(module, "rule_id in location is invalid with state=absent") From 059df3daaa0e59fa6b56bba403b9ee946aa06120 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 9 Jan 2024 07:48:03 +0100 Subject: [PATCH 05/49] Ongoing development. --- plugins/modules/rule.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 1e28af9a0..885f3d091 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -317,7 +317,10 @@ def show_rule(module, base_url, headers, rule_id): def get_existing_rule(module, base_url, headers, ruleset, rule): if rule.get("rule_id"): # We already know whih rule to get - return rule.get("rule_id") + if module.params.get("state") == "absent": + # When deleting and we already know the ID, don't compare + return rule.get("rule_id") + rules = [ show_rule(module, base_url, headers, rule.get("rule_id")) ] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -529,9 +532,9 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] if rule.get("properties") is None or rule.get("properties") == "": exit_failed(module, "Rule properties are required") if rule.get("value_raw") is None or rule.get("value_raw") == "": From f740143d28a327bbd678c89896bb44ef47e43142 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:01:22 +0100 Subject: [PATCH 06/49] Now it's also possible to change existing rules based on a given rule_id. --- plugins/modules/rule.py | 65 +++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 885f3d091..f7f352d6a 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -387,6 +387,42 @@ def create_rule(module, base_url, headers, ruleset, rule): return (r["id"], changed) +def modify_rule(module, base_url, headers, ruleset, rule): + changed = True + rule_id = rule.get("rule_id") + + if not rule_id: + return not changed + + if module.check_mode: + return (None, changed) + + headers["If-Match"] = get_rule_etag(module, base_url, headers, rule_id) + + params = { + "properties": rule["properties"], + "value_raw": rule["value_raw"], + "conditions": rule["conditions"], + } + + api_endpoint = "/objects/rule/" + rule_id + url = base_url + api_endpoint + + info = fetch_url( + module, url, module.jsonify(params), headers=headers, method="PUT" + )[1] + #exit_failed(module, "###### INFO: %s" % str(info)) + + if info["status"] not in [200, 204]: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], info["body"]), + ) + + return changed + + def delete_rule(module, base_url, headers, ruleset, rule): changed = True rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) @@ -532,15 +568,15 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": + if not rule.get("folder"): rule["folder"] = location["folder"] - if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("properties") is None or rule.get("properties") == "": + if not rule.get("rule_id"): + if not rule.get("properties"): exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": + if not rule.get("value_raw"): exit_failed(module, "Rule value_raw is required") # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": + if rule.get("conditions"): rule["conditions"] = { "host_tags": [], "host_labels": [], @@ -559,13 +595,24 @@ def run_module(): exit_ok(module, "Rule does not exist") # If state is present, create the rule elif module.params.get("state") == "present": - (rule_id, created) = create_rule(module, base_url, headers, ruleset, rule) - if created: + action = None + if rule.get("rule_id"): + # Modify an existing rule + rule_id = rule.get("rule_id") + if modify_rule(module, base_url, headers, ruleset, rule): + action = "changed" + else: + # If no rule_id is mentioned, we check if our rule exists. If not, then create it. + (rule_id, changed) = create_rule(module, base_url, headers, ruleset, rule) + if changed: + action = "created" + + if action: # Move rule to specified location, if it's not default if location["position"] != "bottom" and not module.check_mode: move_rule(module, base_url, headers, rule_id, location) - exit_changed(module, "Rule created", rule_id) - exit_ok(module, "Rule already exists", rule_id) + exit_changed(module, "Rule %s" % action, rule_id) + exit_ok(module, "Rule already exists with equal settings", rule_id) # Fallback exit_failed(module, "Unknown error") From add9f81351447ab070a969bdcf642fb244d3e398 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:52:24 +0100 Subject: [PATCH 07/49] Modifying existing rules is now idempotent, at least for some of the rulesets. Depends on the value_raw that is used. --- plugins/modules/rule.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index f7f352d6a..93d0c1ab5 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -394,6 +394,9 @@ def modify_rule(module, base_url, headers, ruleset, rule): if not rule_id: return not changed + if get_existing_rule(module, base_url, headers, ruleset, rule): + return not changed + if module.check_mode: return (None, changed) From 1b51ae97ccf7ba3ab131aad51ce4618193518612 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:53:22 +0100 Subject: [PATCH 08/49] Typo in the rules lookup module integration test. --- tests/integration/targets/lookup_rules/tasks/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index b42e3dc6c..0406251e9 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -68,7 +68,7 @@ vars: rules: "{{ lookup('checkmk.general.rules', ruleset=item, - commebt_regex='Ansible managed', + comment_regex='Ansible managed', server_url=server_url, site=outer_item.site, validate_certs=False, From d30d7a7c48804f170569057462634c312439e0d3 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:53:56 +0100 Subject: [PATCH 09/49] Added an integration test case for modifying existing rules. --- tests/integration/targets/rule/tasks/test.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index b2f13c23c..c74f1b643 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -45,6 +45,45 @@ delegate_to: localhost run_once: true # noqa run-once[task] +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules." + rule: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + ruleset: "{{ item.ruleset }}" + rule: + rule_id: "{{ existing_rule[0].id }}" + properties: { + "description": "Modified this intentionally." + } + state: "present" + vars: + existing_rule:"{{ lookup('checkmk.general.rules', + ruleset=item.ruleset, + comment_regex='Ansible managed', + server_url=server_url, + site=outer_item.site, + validate_certs=False, + automation_user=automation_user, + automation_secret=automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_var_rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." + activation: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + force_foreign_changes: true + sites: + - "{{ outer_item.site }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: server_url: "{{ checkmk_var_server_url }}" From fb5d4aedddc98151115113eac51f9a0e25dc864c Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:57:45 +0100 Subject: [PATCH 10/49] Sanity --- plugins/modules/rule.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 93d0c1ab5..9971e0c46 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -68,7 +68,7 @@ description: Properties of the rule. type: dict rule_id: - description: + description: - If given, it will be C(the only condition) to identify the rule to work on. - When there's no rule found with this id, the task will fail. type: str @@ -300,9 +300,7 @@ def show_rule(module, base_url, headers, rule_id): url = "%s%s" % (base_url, api_endpoint) - response, info = fetch_url( - module, url, headers=headers, method="GET" - ) + response, info = fetch_url(module, url, headers=headers, method="GET") if info["status"] != 200: exit_failed( @@ -320,7 +318,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if module.params.get("state") == "absent": # When deleting and we already know the ID, don't compare return rule.get("rule_id") - rules = [ show_rule(module, base_url, headers, rule.get("rule_id")) ] + rules = [show_rule(module, base_url, headers, rule.get("rule_id"))] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -414,7 +412,6 @@ def modify_rule(module, base_url, headers, ruleset, rule): info = fetch_url( module, url, module.jsonify(params), headers=headers, method="PUT" )[1] - #exit_failed(module, "###### INFO: %s" % str(info)) if info["status"] not in [200, 204]: exit_failed( From 409ee8ea8278437093f6b285c9ce51bb3d1106b0 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 11:12:21 +0100 Subject: [PATCH 11/49] Typo in rule integration test. --- tests/integration/targets/rule/tasks/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index c74f1b643..8029dab10 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -59,7 +59,7 @@ } state: "present" vars: - existing_rule:"{{ lookup('checkmk.general.rules', + existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, comment_regex='Ansible managed', server_url=server_url, From 311885c9cfcb1d8bc3e7c55db30a030c0fc7cdf8 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 11:29:08 +0100 Subject: [PATCH 12/49] Copy & paste issue in rule integration test. --- tests/integration/targets/rule/tasks/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 8029dab10..541edcb0e 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -62,11 +62,11 @@ existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, comment_regex='Ansible managed', - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] From 24dc453686d265d0f1773018e3dd3aa7b3ac22a2 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 23 Jan 2024 09:03:45 +0100 Subject: [PATCH 13/49] Debugged the integration test for the rules module. --- tests/integration/targets/rule/tasks/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 541edcb0e..f380dd7b0 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -55,9 +55,14 @@ rule: rule_id: "{{ existing_rule[0].id }}" properties: { - "description": "Modified this intentionally." + "comment": "{{ existing_rule[0].extensions.properties.comment }}", + "description": "Modified this intentionally.", + "disabled": "{{ existing_rule[0].extensions.properties.disabled }}" } + conditions: "{{ existing_rule[0].extensions.conditions }}" + value_raw: "{{ existing_rule[0].extensions.value_raw | string }}" state: "present" + when: "existing_rule|length>0" vars: existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, From 2c3a9c65a2413538d762b1dc11b19ceaa39ddeec Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Wed, 20 Dec 2023 11:12:30 +0100 Subject: [PATCH 14/49] The rule module has now a parameter rule_id that can be used to identify an existing rule. --- plugins/modules/rule.py | 79 ++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 097acce4e..959196536 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -67,6 +67,11 @@ properties: description: Properties of the rule. type: dict + rule_id: + description: + - If given, it will be C(the only condition) to identify the rule to work on. + - When there's no rule found with this id, the task will fail. + type: str value_raw: description: Rule values as exported from the web interface. type: str @@ -280,6 +285,25 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): module, url, module.jsonify(params), headers=headers, method="GET" ) + if info["status"] != 200: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], str(info)), + ) + + return json.loads(response.read().decode("utf-8")).get("value") + + +def show_rule(module, base_url, headers, rule_id): + api_endpoint = "/objects/rule/" + rule_id + + url = "%s%s" % (base_url, api_endpoint) + + response, info = fetch_url( + module, url, headers=headers, method="GET" + ) + if info["status"] != 200: exit_failed( module, @@ -308,8 +332,12 @@ def get_rule_by_id(module, base_url, headers, rule_id): def get_existing_rule(module, base_url, headers, ruleset, rule): - # Get rules in ruleset - rules = get_rules_in_ruleset(module, base_url, headers, ruleset) + if rule.get("rule_id"): + # We already know whih rule to get + return rule.get("rule_id") + else: + # Get rules in ruleset + rules = get_rules_in_ruleset(module, base_url, headers, ruleset) (value_mod, exc) = safe_eval(rule["value_raw"], include_exceptions=True) if exc is not None: @@ -324,7 +352,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if rules is not None: # Loop through all rules - for r in rules.get("value"): + for r in rules: (value_api, exc) = safe_eval( r["extensions"]["value_raw"], include_exceptions=True ) @@ -338,7 +366,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): and value_api == value_mod ): # If they are the same, return the ID - return r + return r["id"] return None @@ -347,9 +375,9 @@ def create_rule(module, base_url, headers, ruleset, rule): api_endpoint = "/domain-types/rule/collections/all" changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: - return (e["id"], not changed) + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + if rule_id: + return (rule_id, not changed) if module.check_mode: return (None, changed) @@ -382,10 +410,11 @@ def create_rule(module, base_url, headers, ruleset, rule): def delete_rule(module, base_url, headers, ruleset, rule): changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + + if rule_id: if not module.check_mode: - delete_rule_by_id(module, base_url, headers, e["id"]) + delete_rule_by_id(module, base_url, headers, rule_id) return changed return not changed @@ -471,6 +500,7 @@ def run_module(): conditions=dict(type="dict"), properties=dict(type="dict"), value_raw=dict(type="str"), + rule_id=dict(type="str"), location=dict( type="dict", options=dict( @@ -519,23 +549,24 @@ def run_module(): # Get the variables ruleset = module.params.get("ruleset", "") - rule = module.params.get("rule", "") + rule = module.params.get("rule", {}) location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] - if rule.get("properties") is None or rule.get("properties") == "": - exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": - exit_failed(module, "Rule value_raw is required") - # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": - rule["conditions"] = { - "host_tags": [], - "host_labels": [], - "service_labels": [], - } + if rule.get("rule_id") is None or rule.get("rule_id") == "": + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] + if rule.get("properties") is None or rule.get("properties") == "": + exit_failed(module, "Rule properties are required") + if rule.get("value_raw") is None or rule.get("value_raw") == "": + exit_failed(module, "Rule value_raw is required") + # Default to all hosts if conditions arent given + if rule.get("conditions") is None or rule.get("conditions") == "": + rule["conditions"] = { + "host_tags": [], + "host_labels": [], + "service_labels": [], + } if module.params.get("state") == "absent": if location.get("rule_id") is not None: exit_failed(module, "rule_id in location is invalid with state=absent") From 8f7d4a63e6187eaedeff45807e986800b65d0a3b Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 9 Jan 2024 07:48:03 +0100 Subject: [PATCH 15/49] Ongoing development. --- plugins/modules/rule.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 959196536..990594d97 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -334,7 +334,10 @@ def get_rule_by_id(module, base_url, headers, rule_id): def get_existing_rule(module, base_url, headers, ruleset, rule): if rule.get("rule_id"): # We already know whih rule to get - return rule.get("rule_id") + if module.params.get("state") == "absent": + # When deleting and we already know the ID, don't compare + return rule.get("rule_id") + rules = [ show_rule(module, base_url, headers, rule.get("rule_id")) ] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -553,9 +556,9 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given + if rule.get("folder") is None or rule.get("folder") == "": + rule["folder"] = location["folder"] if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("folder") is None or rule.get("folder") == "": - rule["folder"] = location["folder"] if rule.get("properties") is None or rule.get("properties") == "": exit_failed(module, "Rule properties are required") if rule.get("value_raw") is None or rule.get("value_raw") == "": From b39fd6d6eadd1243b6ccce63b320c2ca1034efbf Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:01:22 +0100 Subject: [PATCH 16/49] Now it's also possible to change existing rules based on a given rule_id. --- plugins/modules/rule.py | 65 +++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 990594d97..61c1331d1 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -411,6 +411,42 @@ def create_rule(module, base_url, headers, ruleset, rule): return (r["id"], changed) +def modify_rule(module, base_url, headers, ruleset, rule): + changed = True + rule_id = rule.get("rule_id") + + if not rule_id: + return not changed + + if module.check_mode: + return (None, changed) + + headers["If-Match"] = get_rule_etag(module, base_url, headers, rule_id) + + params = { + "properties": rule["properties"], + "value_raw": rule["value_raw"], + "conditions": rule["conditions"], + } + + api_endpoint = "/objects/rule/" + rule_id + url = base_url + api_endpoint + + info = fetch_url( + module, url, module.jsonify(params), headers=headers, method="PUT" + )[1] + #exit_failed(module, "###### INFO: %s" % str(info)) + + if info["status"] not in [200, 204]: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], info["body"]), + ) + + return changed + + def delete_rule(module, base_url, headers, ruleset, rule): changed = True rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) @@ -556,15 +592,15 @@ def run_module(): location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": + if not rule.get("folder"): rule["folder"] = location["folder"] - if rule.get("rule_id") is None or rule.get("rule_id") == "": - if rule.get("properties") is None or rule.get("properties") == "": + if not rule.get("rule_id"): + if not rule.get("properties"): exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": + if not rule.get("value_raw"): exit_failed(module, "Rule value_raw is required") # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": + if rule.get("conditions"): rule["conditions"] = { "host_tags": [], "host_labels": [], @@ -583,13 +619,24 @@ def run_module(): exit_ok(module, "Rule does not exist") # If state is present, create the rule elif module.params.get("state") == "present": - (rule_id, created) = create_rule(module, base_url, headers, ruleset, rule) - if created: + action = None + if rule.get("rule_id"): + # Modify an existing rule + rule_id = rule.get("rule_id") + if modify_rule(module, base_url, headers, ruleset, rule): + action = "changed" + else: + # If no rule_id is mentioned, we check if our rule exists. If not, then create it. + (rule_id, changed) = create_rule(module, base_url, headers, ruleset, rule) + if changed: + action = "created" + + if action: # Move rule to specified location, if it's not default if location["position"] != "bottom" and not module.check_mode: move_rule(module, base_url, headers, rule_id, location) - exit_changed(module, "Rule created", rule_id) - exit_ok(module, "Rule already exists", rule_id) + exit_changed(module, "Rule %s" % action, rule_id) + exit_ok(module, "Rule already exists with equal settings", rule_id) # Fallback exit_failed(module, "Unknown error") From ed320f64eeba70fccca331c9aa889dcbd96c445d Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Wed, 20 Dec 2023 11:12:30 +0100 Subject: [PATCH 17/49] The rule module has now a parameter rule_id that can be used to identify an existing rule. --- plugins/modules/rule.py | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 61c1331d1..9971e0c46 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -68,7 +68,7 @@ description: Properties of the rule. type: dict rule_id: - description: + description: - If given, it will be C(the only condition) to identify the rule to work on. - When there's no rule found with this id, the task will fail. type: str @@ -300,28 +300,9 @@ def show_rule(module, base_url, headers, rule_id): url = "%s%s" % (base_url, api_endpoint) - response, info = fetch_url( - module, url, headers=headers, method="GET" - ) - - if info["status"] != 200: - exit_failed( - module, - "Error calling API. HTTP code %d. Details: %s, " - % (info["status"], info["body"]), - ) - - return json.loads(response.read().decode("utf-8")) - - -def get_rule_by_id(module, base_url, headers, rule_id): - api_endpoint = "/objects/rule/" + rule_id - - url = base_url + api_endpoint - response, info = fetch_url(module, url, headers=headers, method="GET") - if info["status"] not in [200, 204]: + if info["status"] != 200: exit_failed( module, "Error calling API. HTTP code %d. Details: %s, " @@ -337,7 +318,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if module.params.get("state") == "absent": # When deleting and we already know the ID, don't compare return rule.get("rule_id") - rules = [ show_rule(module, base_url, headers, rule.get("rule_id")) ] + rules = [show_rule(module, base_url, headers, rule.get("rule_id"))] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -346,13 +327,6 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if exc is not None: exit_failed(module, "value_raw in rule has invalid format") - # Get folder from neighbour rule if relative rule_id is given in location - if rule["location"]["rule_id"] is not None: - neighbour_rule = get_rule_by_id( - module, base_url, headers, rule["location"]["rule_id"] - ) - rule["folder"] = neighbour_rule["extensions"]["folder"] - if rules is not None: # Loop through all rules for r in rules: @@ -418,6 +392,9 @@ def modify_rule(module, base_url, headers, ruleset, rule): if not rule_id: return not changed + if get_existing_rule(module, base_url, headers, ruleset, rule): + return not changed + if module.check_mode: return (None, changed) @@ -435,7 +412,6 @@ def modify_rule(module, base_url, headers, ruleset, rule): info = fetch_url( module, url, module.jsonify(params), headers=headers, method="PUT" )[1] - #exit_failed(module, "###### INFO: %s" % str(info)) if info["status"] not in [200, 204]: exit_failed( From aad310f58d11a718d8459e67a5d226b656f5123f Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:53:22 +0100 Subject: [PATCH 18/49] Typo in the rules lookup module integration test. --- tests/integration/targets/lookup_rules/tasks/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index b42e3dc6c..0406251e9 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -68,7 +68,7 @@ vars: rules: "{{ lookup('checkmk.general.rules', ruleset=item, - commebt_regex='Ansible managed', + comment_regex='Ansible managed', server_url=server_url, site=outer_item.site, validate_certs=False, From 461e4b94310ad9f01b68a2c59b9f3ebd00d07d52 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 10:53:56 +0100 Subject: [PATCH 19/49] Added an integration test case for modifying existing rules. --- tests/integration/targets/rule/tasks/test.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index b2f13c23c..c74f1b643 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -45,6 +45,45 @@ delegate_to: localhost run_once: true # noqa run-once[task] +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules." + rule: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + ruleset: "{{ item.ruleset }}" + rule: + rule_id: "{{ existing_rule[0].id }}" + properties: { + "description": "Modified this intentionally." + } + state: "present" + vars: + existing_rule:"{{ lookup('checkmk.general.rules', + ruleset=item.ruleset, + comment_regex='Ansible managed', + server_url=server_url, + site=outer_item.site, + validate_certs=False, + automation_user=automation_user, + automation_secret=automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_var_rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." + activation: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + force_foreign_changes: true + sites: + - "{{ outer_item.site }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: server_url: "{{ checkmk_var_server_url }}" From 8407c415d40f65ec91e1f2e6b7301f35dbff78a1 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 11:12:21 +0100 Subject: [PATCH 20/49] Typo in rule integration test. --- tests/integration/targets/rule/tasks/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index c74f1b643..8029dab10 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -59,7 +59,7 @@ } state: "present" vars: - existing_rule:"{{ lookup('checkmk.general.rules', + existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, comment_regex='Ansible managed', server_url=server_url, From 15cfe63268b45efbd9f32376d0edff30bf2670f7 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Fri, 19 Jan 2024 11:29:08 +0100 Subject: [PATCH 21/49] Copy & paste issue in rule integration test. --- tests/integration/targets/rule/tasks/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 8029dab10..541edcb0e 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -62,11 +62,11 @@ existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, comment_regex='Ansible managed', - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] From 05b4ef8cf4386f080d6d7f9c8cdc3cf04655fdfe Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 23 Jan 2024 09:03:45 +0100 Subject: [PATCH 22/49] Debugged the integration test for the rules module. --- tests/integration/targets/rule/tasks/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 541edcb0e..f380dd7b0 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -55,9 +55,14 @@ rule: rule_id: "{{ existing_rule[0].id }}" properties: { - "description": "Modified this intentionally." + "comment": "{{ existing_rule[0].extensions.properties.comment }}", + "description": "Modified this intentionally.", + "disabled": "{{ existing_rule[0].extensions.properties.disabled }}" } + conditions: "{{ existing_rule[0].extensions.conditions }}" + value_raw: "{{ existing_rule[0].extensions.value_raw | string }}" state: "present" + when: "existing_rule|length>0" vars: existing_rule: "{{ lookup('checkmk.general.rules', ruleset=item.ruleset, From 30bf87a9bc65cccc4f3277748dfd8829c5d22c93 Mon Sep 17 00:00:00 2001 From: Lars Getwan Date: Tue, 23 Jan 2024 16:32:09 +0100 Subject: [PATCH 23/49] Manually merge pull request #517 from meni2029/fix/module_rule_relative_id into the branch feature/module-rules-rule_id --- plugins/modules/rule.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 9971e0c46..a446c98a2 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -295,7 +295,7 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): return json.loads(response.read().decode("utf-8")).get("value") -def show_rule(module, base_url, headers, rule_id): +def get_rule_by_id(module, base_url, headers, rule_id): api_endpoint = "/objects/rule/" + rule_id url = "%s%s" % (base_url, api_endpoint) @@ -318,7 +318,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if module.params.get("state") == "absent": # When deleting and we already know the ID, don't compare return rule.get("rule_id") - rules = [show_rule(module, base_url, headers, rule.get("rule_id"))] + rules = [get_rule_by_id(module, base_url, headers, rule.get("rule_id"))] else: # Get rules in ruleset rules = get_rules_in_ruleset(module, base_url, headers, ruleset) @@ -327,6 +327,13 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if exc is not None: exit_failed(module, "value_raw in rule has invalid format") + # Get folder from neighbour rule if relative rule_id is given in location + if rule["location"]["rule_id"] is not None: + neighbour_rule = get_rule_by_id( + module, base_url, headers, rule["location"]["rule_id"] + ) + rule["folder"] = neighbour_rule["extensions"]["folder"] + if rules is not None: # Loop through all rules for r in rules: From a846fb78c722c437db09d5da7019a40983f8b6ac Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 13 Feb 2024 17:59:39 -0500 Subject: [PATCH 24/49] Update lookup_folder with new variables. --- .../targets/lookup_folder/tasks/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index 647dc014d..1e55b046c 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -57,3 +57,18 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify folder criticality using ENV vars." + ansible.builtin.assert: + that: "extensions.attributes.tag_criticality == checkmk_folder.criticality" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + extensions: "{{ lookup('checkmk.general.folder', + checkmk_folder.path) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] From e19fd625656b0ce703890fe69440e0f1e2fac9aa Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Wed, 14 Feb 2024 11:18:43 -0500 Subject: [PATCH 25/49] Update lookup_bakery with new variables. --- .../targets/lookup_bakery/tasks/test.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/integration/targets/lookup_bakery/tasks/test.yml b/tests/integration/targets/lookup_bakery/tasks/test.yml index b594758f0..d41fbc773 100644 --- a/tests/integration/targets/lookup_bakery/tasks/test.yml +++ b/tests/integration/targets/lookup_bakery/tasks/test.yml @@ -20,3 +20,24 @@ ("'initialized' in looked_up_bakery.msg") or ("'stopped' in looked_up_bakery.msg") or ("'exception' in looked_up_bakery.msg") + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk bakery status using ENV vars." + ansible.builtin.debug: + msg: "Bakery status is {{ bakery }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + bakery: "{{ lookup('checkmk.general.bakery') }}" + delegate_to: localhost + register: looked_up_bakery + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify bakery status." + ansible.builtin.assert: + that: ("'finished' in looked_up_bakery.msg") or + ("'running' in looked_up_bakery.msg") or + ("'initialized' in looked_up_bakery.msg") or + ("'stopped' in looked_up_bakery.msg") or + ("'exception' in looked_up_bakery.msg") From f5aadb735a8563ec9ed9a8edc13672c60c4261aa Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 09:13:48 -0500 Subject: [PATCH 26/49] Update changelog template. --- changelogs/template.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/changelogs/template.yml b/changelogs/template.yml index 4931365a8..d4b43fd17 100644 --- a/changelogs/template.yml +++ b/changelogs/template.yml @@ -21,12 +21,20 @@ # For changes that are not really scoped (for example, which affect a whole collection), use the following format: # - Description starting with an uppercase letter and ending with a dot at the very end. Multiple sentences are allowed. +# Tipps: +# You can write multi line changelogs like this: +# - Module name - This is a very long and detailed +# changelog line, so we will split it into several +# lines, just like this. + ## Possible keys: # # release_summary # Adds a single line release summary to the changelog. # breaking_changes -# Changes that break existing playbooks or roles. This includes any change to existing behavior that forces users to update tasks. Displayed in both the changelogs and the Porting Guides. +# Changes that break existing playbooks or roles. +# This includes any change to existing behavior that forces users to update tasks. +# Displayed in both the changelogs and the Porting Guides. # major_changes # Major changes to Ansible itself. Generally does not include module or plugin changes. Displayed in both the changelogs and the Porting Guides. # minor_changes From 6e671d3ffe39cfed42622af8964f838a91e4cb21 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 10:20:18 -0500 Subject: [PATCH 27/49] Add changelog and extend documentation. --- changelogs/fragments/lookups.yml | 4 ++++ plugins/lookup/bakery.py | 13 ++++++++++++- plugins/lookup/folder.py | 11 +++++++++++ plugins/lookup/folders.py | 18 ++++++++++++++++++ plugins/lookup/host.py | 11 +++++++++++ plugins/lookup/hosts.py | 14 ++++++++++++++ plugins/lookup/rule.py | 11 +++++++++++ plugins/lookup/rules.py | 14 ++++++++++++++ plugins/lookup/ruleset.py | 11 +++++++++++ plugins/lookup/rulesets.py | 14 ++++++++++++++ plugins/lookup/version.py | 11 +++++++++++ 11 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/lookups.yml diff --git a/changelogs/fragments/lookups.yml b/changelogs/fragments/lookups.yml new file mode 100644 index 000000000..c9c3e4d80 --- /dev/null +++ b/changelogs/fragments/lookups.yml @@ -0,0 +1,4 @@ +minor_changes: + - Lookup modules - Enable usage of ini files, environment and inventory variables + to configure basic settings for the lookup plugins, like the server_url and site + alongside the authentication options. Refer to the module documentation for details. diff --git a/plugins/lookup/bakery.py b/plugins/lookup/bakery.py index 0346e3122..63fdc700d 100644 --- a/plugins/lookup/bakery.py +++ b/plugins/lookup/bakery.py @@ -83,7 +83,7 @@ EXAMPLES = """ - name: "Show bakery status" - debug: + ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: bakery: "{{ lookup('checkmk.general.bakery', @@ -93,6 +93,17 @@ automation_user=automation_user, automation_secret=automation_secret )}}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Bakery status is {{ bakery }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + bakery: "{{ lookup('checkmk.general.bakery') }}" """ RETURN = """ diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 56a204ca2..22965b838 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -100,6 +100,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of folder /network: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" """ RETURN = """ diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index 8a3a9708a..570337c15 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -136,6 +136,24 @@ loop: "{{ looping|subelements('members.hosts.value') }}" loop_control: label: "{{ item.0.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Folder tree: {{ item.id }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + loop: "{{ + lookup('checkmk.general.folders', + '~', + show_hosts=False, + recursive=True, + ) }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/host.py b/plugins/lookup/host.py index a4145221d..d94d8485c 100644 --- a/plugins/lookup/host.py +++ b/plugins/lookup/host.py @@ -107,6 +107,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of host example: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}" """ RETURN = """ diff --git a/plugins/lookup/hosts.py b/plugins/lookup/hosts.py index 79f2e744e..a98f5c5ab 100644 --- a/plugins/lookup/hosts.py +++ b/plugins/lookup/hosts.py @@ -104,6 +104,20 @@ }}" loop_control: label: "{{ item.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + loop: "{{ + lookup('checkmk.general.hosts', effective_attributes=True) }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/rule.py b/plugins/lookup/rule.py index 441b3ac71..ec3e4e1f3 100644 --- a/plugins/lookup/rule.py +++ b/plugins/lookup/rule.py @@ -100,6 +100,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}" """ RETURN = """ diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py index a9b954f8c..842c98ac3 100644 --- a/plugins/lookup/rules.py +++ b/plugins/lookup/rules.py @@ -129,6 +129,20 @@ }}" loop_control: label: "{{ item.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + loop: "{{ + lookup('checkmk.general.rules', ruleset='host_groups') }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/ruleset.py b/plugins/lookup/ruleset.py index d25d1cb05..161ce8547 100644 --- a/plugins/lookup/ruleset.py +++ b/plugins/lookup/ruleset.py @@ -100,6 +100,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}" """ RETURN = """ diff --git a/plugins/lookup/rulesets.py b/plugins/lookup/rulesets.py index 349920375..a8c39dd8a 100644 --- a/plugins/lookup/rulesets.py +++ b/plugins/lookup/rulesets.py @@ -139,6 +139,20 @@ }}" loop_control: label: "{{ item.0.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset {{ item.extension.name }} is deprecated." + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + loop: "{{ + lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" + loop_control: + label: "{{ item.0.id }}" """ RETURN = """ diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 5a87f4ded..8d293ba68 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -92,6 +92,17 @@ automation_user=my_user, automation_secret=my_secret )}}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Server version is {{ version }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_validate_certs: false + attributes: "{{ lookup('checkmk.general.version') }}" """ RETURN = """ From 68940f841df56eda2460964c0ae94e806e7ad4f6 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 12:47:28 -0500 Subject: [PATCH 28/49] Fix variable names. --- plugins/lookup/bakery.py | 6 +++--- plugins/lookup/folder.py | 6 +++--- plugins/lookup/folders.py | 6 +++--- plugins/lookup/host.py | 6 +++--- plugins/lookup/hosts.py | 6 +++--- plugins/lookup/rule.py | 6 +++--- plugins/lookup/rules.py | 6 +++--- plugins/lookup/ruleset.py | 6 +++--- plugins/lookup/rulesets.py | 6 +++--- plugins/lookup/version.py | 6 +++--- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/plugins/lookup/bakery.py b/plugins/lookup/bakery.py index 63fdc700d..712006101 100644 --- a/plugins/lookup/bakery.py +++ b/plugins/lookup/bakery.py @@ -100,9 +100,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false bakery: "{{ lookup('checkmk.general.bakery') }}" """ diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 22965b838..bf00737f6 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -107,9 +107,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" """ diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index 570337c15..03d260728 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -143,9 +143,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.folders', '~', diff --git a/plugins/lookup/host.py b/plugins/lookup/host.py index d94d8485c..6db71d786 100644 --- a/plugins/lookup/host.py +++ b/plugins/lookup/host.py @@ -114,9 +114,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}" """ diff --git a/plugins/lookup/hosts.py b/plugins/lookup/hosts.py index a98f5c5ab..d2ac43106 100644 --- a/plugins/lookup/hosts.py +++ b/plugins/lookup/hosts.py @@ -111,9 +111,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.hosts', effective_attributes=True) }}" loop_control: diff --git a/plugins/lookup/rule.py b/plugins/lookup/rule.py index ec3e4e1f3..e6c0447ff 100644 --- a/plugins/lookup/rule.py +++ b/plugins/lookup/rule.py @@ -107,9 +107,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}" """ diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py index 842c98ac3..9d0620b2f 100644 --- a/plugins/lookup/rules.py +++ b/plugins/lookup/rules.py @@ -136,9 +136,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups') }}" loop_control: diff --git a/plugins/lookup/ruleset.py b/plugins/lookup/ruleset.py index 161ce8547..af23d7dd8 100644 --- a/plugins/lookup/ruleset.py +++ b/plugins/lookup/ruleset.py @@ -107,9 +107,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}" """ diff --git a/plugins/lookup/rulesets.py b/plugins/lookup/rulesets.py index a8c39dd8a..fb50b21f2 100644 --- a/plugins/lookup/rulesets.py +++ b/plugins/lookup/rulesets.py @@ -146,9 +146,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" loop_control: diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 8d293ba68..e603819a6 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -99,9 +99,9 @@ vars: ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.version') }}" """ From 0433f903241a523bcc476dd5ff24ea010e33f9d6 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 13:57:45 -0500 Subject: [PATCH 29/49] Add initial set of tests using the new variables from #546. --- .../files/includes/vars/global.yml | 6 ++++++ .../targets/lookup_bakery/tasks/test.yml | 7 +------ .../targets/lookup_folder/tasks/test.yml | 11 ++--------- .../targets/lookup_folders/tasks/test.yml | 15 ++++++++++++--- .../targets/lookup_host/tasks/test.yml | 8 ++++++++ .../targets/lookup_hosts/tasks/test.yml | 8 ++++++++ .../targets/lookup_rules/tasks/test.yml | 19 +++++++++++++++++++ .../targets/lookup_rulesets/tasks/test.yml | 18 ++++++++++++++++++ .../targets/lookup_version/tasks/test.yml | 7 +++++++ 9 files changed, 81 insertions(+), 18 deletions(-) diff --git a/tests/integration/files/includes/vars/global.yml b/tests/integration/files/includes/vars/global.yml index 57f8bb073..e56ed6faf 100644 --- a/tests/integration/files/includes/vars/global.yml +++ b/tests/integration/files/includes/vars/global.yml @@ -15,3 +15,9 @@ checkmk_server_edition_mapping: cee: enterprise cce: cloud cme: managed + +ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" +ansible_lookup_checkmk_site: "{{ outer_item.site }}" +ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" +ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" +ansible_lookup_checkmk_validate_certs: false diff --git a/tests/integration/targets/lookup_bakery/tasks/test.yml b/tests/integration/targets/lookup_bakery/tasks/test.yml index d41fbc773..034b88552 100644 --- a/tests/integration/targets/lookup_bakery/tasks/test.yml +++ b/tests/integration/targets/lookup_bakery/tasks/test.yml @@ -21,15 +21,10 @@ ("'stopped' in looked_up_bakery.msg") or ("'exception' in looked_up_bakery.msg") -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk bakery status using ENV vars." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: - ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" - ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false bakery: "{{ lookup('checkmk.general.bakery') }}" delegate_to: localhost register: looked_up_bakery diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index 1e55b046c..f028883c9 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -58,17 +58,10 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify folder criticality using ENV vars." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: that: "extensions.attributes.tag_criticality == checkmk_folder.criticality" vars: - ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" - ansible_lookup_checkmk_site: "{{ outer_item.site }}" - ansible_lookup_automation_user: "{{ checkmk_var_automation_user }}" - ansible_lookup_automation_secret: "{{ checkmk_var_automation_secret }}" - ansible_lookup_validate_certs: false - extensions: "{{ lookup('checkmk.general.folder', - checkmk_folder.path) - }}" + extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path) }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index befebd766..8852389d4 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -14,7 +14,7 @@ run_once: true # noqa run-once[task] loop: "{{ checkmk_var_folders }}" -- name: "Get all folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all folders." ansible.builtin.debug: var: folders vars: @@ -30,7 +30,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "Get list of all folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get list of all folders." ansible.builtin.debug: msg: "Criticality of {{ item.id }} is {{ item.extensions.attributes.tag_criticality | default('N/A') }}" loop: "{{ lookup('checkmk.general.folders', @@ -47,7 +47,7 @@ loop_control: label: "{{ item.id }}" -- name: "Verify number of folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders." ansible.builtin.assert: # The looked up list contains the main folder, as well. that: "( 1 + checkmk_var_folders|length ) == folders|length" @@ -63,3 +63,12 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders." + ansible.builtin.assert: + # The looked up list contains the main folder, as well. + that: "( 1 + checkmk_var_folders|length ) == folders|length" + vars: + folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index 281d673a0..e10ac167d 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -44,3 +44,11 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "checkmk_host.alias == extensions.attributes.alias" + vars: + extensions: "{{ lookup('checkmk.general.host', checkmk_host.name) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index 3e04d6b30..e9b50d1e7 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -44,3 +44,11 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "checkmk_hosts|length == hosts|length" + vars: + folders: "{{ lookup('checkmk.general.hosts') }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index 675237540..eda80fa72 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -94,3 +94,22 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ cpu_load_ruleset.rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rule." + ansible.builtin.debug: + var: "rule" + vars: + rule: "{{ lookup('checkmk.general.rule', rule_id=item.id) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ cpu_load_ruleset.rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rules." + ansible.builtin.assert: + # Check the number of rules + that: rules|length == 1 + vars: + rules: "{{ lookup('checkmk.general.rules', ruleset=item, commebt_regex='Ansible managed') }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_rulesets }}" diff --git a/tests/integration/targets/lookup_rulesets/tasks/test.yml b/tests/integration/targets/lookup_rulesets/tasks/test.yml index 8f7482982..94eb8d998 100644 --- a/tests/integration/targets/lookup_rulesets/tasks/test.yml +++ b/tests/integration/targets/lookup_rulesets/tasks/test.yml @@ -80,3 +80,21 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_ruleset_regexes }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: ruleset." + ansible.builtin.assert: + # For each rule that we created, check, if the number of rules in its ruleset is 1. + that: "ruleset.number_of_rules == 1" + vars: + ruleset: "{{ lookup('checkmk.general.ruleset', ruleset=item) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_ruleset_regexes }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rulesets." + ansible.builtin.debug: + var: rulesets + vars: + rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index e4409f64c..b156f5df9 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -16,3 +16,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify Checkmk version." ansible.builtin.assert: that: "outer_item.version in looked_up_version.msg" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk version." + ansible.builtin.assert: + that: "outer_item.version in looked_up_version.msg" + vars: + version: "{{ lookup('checkmk.general.version') }}" + delegate_to: localhost From 45d04c4669b6fcda803dc2d198165fbf714f78f1 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 13:58:14 -0500 Subject: [PATCH 30/49] Add changelogs. --- changelogs/fragments/folder.yml | 3 +++ changelogs/fragments/release_summary.yml | 1 + 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/folder.yml create mode 100644 changelogs/fragments/release_summary.yml diff --git a/changelogs/fragments/folder.yml b/changelogs/fragments/folder.yml new file mode 100644 index 000000000..e95d55914 --- /dev/null +++ b/changelogs/fragments/folder.yml @@ -0,0 +1,3 @@ +minor_changes: + - Folder module - Extend attribute management. Please refer to the module documentation + for more details. diff --git a/changelogs/fragments/release_summary.yml b/changelogs/fragments/release_summary.yml new file mode 100644 index 000000000..61a046a26 --- /dev/null +++ b/changelogs/fragments/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Folders, build related changed and the environment." From 89bd427779357f9d870364fee42a034fb579cd93 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 13:58:32 -0500 Subject: [PATCH 31/49] Update doc fragment. --- plugins/doc_fragments/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/doc_fragments/common.py b/plugins/doc_fragments/common.py index d70c16134..d0ed25cd9 100644 --- a/plugins/doc_fragments/common.py +++ b/plugins/doc_fragments/common.py @@ -7,7 +7,7 @@ class ModuleDocFragment(object): DOCUMENTATION = r""" options: server_url: - description: The base url of your Checkmk server. + description: The base url of your Checkmk server including the protocol. required: true type: str site: From 35611d2d153cbe87db1214a04fe2521e5012e5e7 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 14:01:24 -0500 Subject: [PATCH 32/49] Bump Checkmk versions. --- roles/agent/README.md | 2 +- roles/agent/defaults/main.yml | 2 +- roles/agent/molecule/2.1.0/group_vars/all.yml | 2 +- roles/agent/molecule/2.2.0/group_vars/all.yml | 2 +- roles/server/README.md | 2 +- roles/server/defaults/main.yml | 2 +- roles/server/molecule/2.1.0/group_vars/all.yml | 2 +- roles/server/molecule/2.2.0/group_vars/all.yml | 2 +- scripts/release.sh | 4 ++-- tests/integration/targets/activation/vars/main.yml | 6 +++--- tests/integration/targets/bakery/vars/main.yml | 4 ++-- tests/integration/targets/contact_group/vars/main.yml | 6 +++--- tests/integration/targets/discovery/vars/main.yml | 6 +++--- tests/integration/targets/downtime/vars/main.yml | 6 +++--- tests/integration/targets/folder/vars/main.yml | 6 +++--- tests/integration/targets/host/vars/main.yml | 6 +++--- tests/integration/targets/host_group/vars/main.yml | 8 ++++---- tests/integration/targets/lookup_bakery/vars/main.yml | 4 ++-- tests/integration/targets/lookup_folder/vars/main.yml | 6 +++--- tests/integration/targets/lookup_folders/vars/main.yml | 6 +++--- tests/integration/targets/lookup_host/vars/main.yml | 6 +++--- tests/integration/targets/lookup_hosts/vars/main.yml | 6 +++--- tests/integration/targets/lookup_rules/vars/main.yml | 6 +++--- tests/integration/targets/lookup_rulesets/vars/main.yml | 6 +++--- tests/integration/targets/lookup_version/vars/main.yml | 6 +++--- tests/integration/targets/password/vars/main.yml | 8 ++++---- tests/integration/targets/rule/vars/main.yml | 6 +++--- tests/integration/targets/service_group/vars/main.yml | 8 ++++---- tests/integration/targets/tag_group/vars/main.yml | 8 ++++---- tests/integration/targets/timeperiod/vars/main.yml | 6 +++--- tests/integration/targets/user/vars/main.yml | 8 ++++---- 31 files changed, 79 insertions(+), 79 deletions(-) diff --git a/roles/agent/README.md b/roles/agent/README.md index cbd697aec..cb7d55538 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -13,7 +13,7 @@ It can be installed as easy as running: ## Role Variables - checkmk_agent_version: "2.2.0p19" + checkmk_agent_version: "2.2.0p22" The Checkmk version of the site your agents will talk to. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index 134a878e6..d99c3a1f1 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_version: "2.2.0p19" +checkmk_agent_version: "2.2.0p22" checkmk_agent_edition: cre checkmk_agent_server_protocol: http checkmk_agent_server: localhost diff --git a/roles/agent/molecule/2.1.0/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index 1a2081859..23df43011 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p38" +checkmk_var_version: "2.1.0p39" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/agent/molecule/2.2.0/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index fe4bdf2f3..2d9a1d6d6 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p19" +checkmk_var_version: "2.2.0p22" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/server/README.md b/roles/server/README.md index 40b4e195e..3d679da43 100644 --- a/roles/server/README.md +++ b/roles/server/README.md @@ -25,7 +25,7 @@ To learn about the distributions used in automated tests, inspect the correspond ## Role Variables - checkmk_server_version: "2.2.0p19" + checkmk_server_version: "2.2.0p22" The global Checkmk version. This is used for installing Checkmk. To manage sites and their version, see `checkmk_server_sites`. diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 5d965d8e9..62e6dd721 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -24,7 +24,7 @@ checkmk_server_server_stable_os: - Ubuntu-20 - Ubuntu-22 -checkmk_server_version: "2.2.0p19" +checkmk_server_version: "2.2.0p22" checkmk_server_edition: cre checkmk_server_verify_setup: 'true' diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index db44b60ee..8baa9a637 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p38" +checkmk_var_version: "2.1.0p39" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/molecule/2.2.0/group_vars/all.yml b/roles/server/molecule/2.2.0/group_vars/all.yml index 9b04ff2e5..902bdc3ae 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p19" +checkmk_var_version: "2.2.0p22" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/scripts/release.sh b/scripts/release.sh index 3c0cd27f1..328c6b1a4 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,8 +16,8 @@ collection_dir="${script_dir%/*}" # Update these as necessary: checkmk_ancient="2.0.0p39" -checkmk_oldstable="2.1.0p38" -checkmk_stable="2.2.0p19" +checkmk_oldstable="2.1.0p39" +checkmk_stable="2.2.0p22" while getopts 's:t:' OPTION; do case "$OPTION" in diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index 839248fdd..f55a7fb56 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 8f0136326..f390261b6 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index 3fb169f3d..124c01d29 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index ca308fbd7..53e43630a 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index 839248fdd..f55a7fb56 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 9986aed15..30d015abd 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index 34da9fa7f..239cd82ac 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index a1e40fe1f..f6facb348 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cme" site: "stable_cme" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_bakery/vars/main.yml b/tests/integration/targets/lookup_bakery/vars/main.yml index a28bca57c..3809fd273 100644 --- a/tests/integration/targets/lookup_bakery/vars/main.yml +++ b/tests/integration/targets/lookup_bakery/vars/main.yml @@ -1,8 +1,8 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index a389e7128..6fed2d247 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index 37681c6ef..f838892b0 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index 0b00fd4b6..3b5e6be7f 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index b84cd157d..c370444f5 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_rules/vars/main.yml b/tests/integration/targets/lookup_rules/vars/main.yml index d4c1b2747..5f85c1230 100644 --- a/tests/integration/targets/lookup_rules/vars/main.yml +++ b/tests/integration/targets/lookup_rules/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_rulesets/vars/main.yml b/tests/integration/targets/lookup_rulesets/vars/main.yml index ce9415dbb..cef6b9a8a 100644 --- a/tests/integration/targets/lookup_rulesets/vars/main.yml +++ b/tests/integration/targets/lookup_rulesets/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 334a5163a..a622b3980 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index 0ca3adfe3..ad69bd9f9 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cme" site: "stable_cme" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 43aca7341..9a019eb6e 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index 8ca906c69..7b7b69f17 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cme" site: "stable_cme" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index cc593be7c..c8cd69b17 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cme" site: "stable_cme" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index 37f0299b3..58d8a131b 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index beb368299..3da150a1c 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cme" site: "stable_cme" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cre" site: "stable_cre" - - version: "2.2.0p19" + - version: "2.2.0p22" edition: "cee" site: "stable_cee" - - version: "2.1.0p38" + - version: "2.1.0p39" edition: "cre" site: "old_cre" From bdc2fad7d1e0b65d540eb5f44804a3f34c9b6656 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 15 Feb 2024 14:01:33 -0500 Subject: [PATCH 33/49] Bump collection version. --- SUPPORT.md | 1 + galaxy.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SUPPORT.md b/SUPPORT.md index 80ebb253a..8700749a5 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -49,3 +49,4 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 4.0.1 | 2.0.0p39, 2.1.0p36, 2.2.0p16 | 2.14, 2.15, 2.16 | None 4.1.0 | 2.0.0p39, 2.1.0p37, 2.2.0p17 | 2.14, 2.15, 2.16 | None 4.2.0 | 2.0.0p39, 2.1.0p38, 2.2.0p19 | 2.14, 2.15, 2.16 | None +4.3.0 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None diff --git a/galaxy.yml b/galaxy.yml index 8e1ad3332..028a6ee41 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ name: general # The version of the collection. Must be compatible with semantic versioning -version: 4.2.0 +version: 4.3.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md From 160f068126bc27b1b7bdcbd95d03704f8a7e3b6d Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 09:18:24 -0500 Subject: [PATCH 34/49] Bugfix. --- tests/integration/targets/lookup_version/tasks/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index b156f5df9..63142308f 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -17,9 +17,10 @@ ansible.builtin.assert: that: "outer_item.version in looked_up_version.msg" -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk version." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: that: "outer_item.version in looked_up_version.msg" vars: version: "{{ lookup('checkmk.general.version') }}" delegate_to: localhost + register: looked_up_version From d46ce0a06a79625d0a9cbed48aeab516243f7285 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 09:18:46 -0500 Subject: [PATCH 35/49] Enable extended integration tests, using a hack. --- .../integration/files/includes/vars/global.yml | 12 ++++++++---- .../targets/lookup_bakery/tasks/test.yml | 18 +++++++----------- .../targets/lookup_folder/tasks/test.yml | 1 + .../targets/lookup_folders/tasks/test.yml | 3 ++- .../targets/lookup_host/tasks/test.yml | 1 + .../targets/lookup_hosts/tasks/test.yml | 1 + .../targets/lookup_rules/tasks/test.yml | 2 ++ .../targets/lookup_rulesets/tasks/test.yml | 2 ++ .../targets/lookup_version/tasks/test.yml | 1 + 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/tests/integration/files/includes/vars/global.yml b/tests/integration/files/includes/vars/global.yml index e56ed6faf..f243be9f5 100644 --- a/tests/integration/files/includes/vars/global.yml +++ b/tests/integration/files/includes/vars/global.yml @@ -16,8 +16,12 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" -ansible_lookup_checkmk_site: "{{ outer_item.site }}" -ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" -ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + +# This is a very hacky workaround, as it is not possible to assign variables +# to other variables when using them in lookup modules. +ansible_lookup_checkmk_server_url: "http://127.0.0.1" +ansible_lookup_checkmk_site: "stable_cee" # This is especially hacky. + # All integration tests were adapted to run the specific task only on this site. +ansible_lookup_checkmk_automation_user: "cmkadmin" +ansible_lookup_checkmk_automation_secret: "Sup3rSec4et!" ansible_lookup_checkmk_validate_certs: false diff --git a/tests/integration/targets/lookup_bakery/tasks/test.yml b/tests/integration/targets/lookup_bakery/tasks/test.yml index 034b88552..a24572023 100644 --- a/tests/integration/targets/lookup_bakery/tasks/test.yml +++ b/tests/integration/targets/lookup_bakery/tasks/test.yml @@ -22,17 +22,13 @@ ("'exception' in looked_up_bakery.msg") - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." - ansible.builtin.debug: - msg: "Bakery status is {{ bakery }}" + ansible.builtin.assert: + that: ("'finished' in bakery.msg") or + ("'running' in bakery.msg") or + ("'initialized' in bakery.msg") or + ("'stopped' in bakery.msg") or + ("'exception' in bakery.msg") vars: bakery: "{{ lookup('checkmk.general.bakery') }}" delegate_to: localhost - register: looked_up_bakery - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify bakery status." - ansible.builtin.assert: - that: ("'finished' in looked_up_bakery.msg") or - ("'running' in looked_up_bakery.msg") or - ("'initialized' in looked_up_bakery.msg") or - ("'stopped' in looked_up_bakery.msg") or - ("'exception' in looked_up_bakery.msg") + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index f028883c9..11522c352 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -65,3 +65,4 @@ extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path) }}" delegate_to: localhost run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index 8852389d4..f7109c8bc 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -64,7 +64,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: # The looked up list contains the main folder, as well. that: "( 1 + checkmk_var_folders|length ) == folders|length" @@ -72,3 +72,4 @@ folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}" delegate_to: localhost run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index e10ac167d..c5f98fb5f 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -52,3 +52,4 @@ extensions: "{{ lookup('checkmk.general.host', checkmk_host.name) }}" delegate_to: localhost run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index e9b50d1e7..8642c7ad3 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -52,3 +52,4 @@ folders: "{{ lookup('checkmk.general.hosts') }}" delegate_to: localhost run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index eda80fa72..3189b24af 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -103,6 +103,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ cpu_load_ruleset.rules }}" + when: outer_item.edition == "stable_cee" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rules." ansible.builtin.assert: @@ -113,3 +114,4 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_rulesets }}" + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rulesets/tasks/test.yml b/tests/integration/targets/lookup_rulesets/tasks/test.yml index 94eb8d998..4055ea615 100644 --- a/tests/integration/targets/lookup_rulesets/tasks/test.yml +++ b/tests/integration/targets/lookup_rulesets/tasks/test.yml @@ -90,6 +90,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_ruleset_regexes }}" + when: outer_item.edition == "stable_cee" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rulesets." ansible.builtin.debug: @@ -98,3 +99,4 @@ rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}" delegate_to: localhost run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index 63142308f..49dfb9ae7 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -24,3 +24,4 @@ version: "{{ lookup('checkmk.general.version') }}" delegate_to: localhost register: looked_up_version + when: outer_item.edition == "stable_cee" From 28ac0dc3fd9e6ac2e888feb79902a64831919186 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 11:09:18 -0500 Subject: [PATCH 36/49] Document known issues and limitations. --- changelogs/fragments/lookups.yml | 7 ++++++- plugins/lookup/bakery.py | 2 ++ plugins/lookup/folder.py | 2 ++ plugins/lookup/folders.py | 2 ++ plugins/lookup/host.py | 2 ++ plugins/lookup/hosts.py | 2 ++ plugins/lookup/rule.py | 2 ++ plugins/lookup/rules.py | 2 ++ plugins/lookup/ruleset.py | 2 ++ plugins/lookup/rulesets.py | 2 ++ plugins/lookup/version.py | 2 ++ 11 files changed, 26 insertions(+), 1 deletion(-) diff --git a/changelogs/fragments/lookups.yml b/changelogs/fragments/lookups.yml index c9c3e4d80..1c8d0172f 100644 --- a/changelogs/fragments/lookups.yml +++ b/changelogs/fragments/lookups.yml @@ -1,4 +1,9 @@ minor_changes: - Lookup modules - Enable usage of ini files, environment and inventory variables - to configure basic settings for the lookup plugins, like the server_url and site + to configure basic settings for the lookup plugins, like e.g., the server_url or site alongside the authentication options. Refer to the module documentation for details. + +known_issues: + - Lookup modules - When using inventory variables to configure e.g., the server_url, + it is not possible to assign other variables to these variables. + This is a limitation of Ansble itself. diff --git a/plugins/lookup/bakery.py b/plugins/lookup/bakery.py index 712006101..6308bb351 100644 --- a/plugins/lookup/bakery.py +++ b/plugins/lookup/bakery.py @@ -79,6 +79,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index bf00737f6..a2b5db1cd 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index 03d260728..4a18d7aaf 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -96,6 +96,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/host.py b/plugins/lookup/host.py index 6db71d786..af9a191fc 100644 --- a/plugins/lookup/host.py +++ b/plugins/lookup/host.py @@ -89,6 +89,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/hosts.py b/plugins/lookup/hosts.py index d2ac43106..50756e84a 100644 --- a/plugins/lookup/hosts.py +++ b/plugins/lookup/hosts.py @@ -86,6 +86,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/rule.py b/plugins/lookup/rule.py index e6c0447ff..105f39034 100644 --- a/plugins/lookup/rule.py +++ b/plugins/lookup/rule.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py index 9d0620b2f..c36349ea7 100644 --- a/plugins/lookup/rules.py +++ b/plugins/lookup/rules.py @@ -93,6 +93,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/ruleset.py b/plugins/lookup/ruleset.py index af23d7dd8..790fd7db9 100644 --- a/plugins/lookup/ruleset.py +++ b/plugins/lookup/ruleset.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/rulesets.py b/plugins/lookup/rulesets.py index fb50b21f2..10acc985d 100644 --- a/plugins/lookup/rulesets.py +++ b/plugins/lookup/rulesets.py @@ -102,6 +102,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index e603819a6..389876af2 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -79,6 +79,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ From a01a6d3f381d38a1508c9d0d5e3bbd1598abab08 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 11:23:53 -0500 Subject: [PATCH 37/49] Minor update to README. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5d32abd4e..498975512 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ Checkmk and keep your daily operations smooth and efficient. ## Here be dragons! This collection is provided AS IS and we cannot guarantee proper functionality. + Additionally, there is no commercial support whatsoever! + This is an open source endeavour, on which we want to collaborate with the community. [![Ansible Sanity Tests](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ansible-sanity-tests.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ansible-sanity-tests.yaml) @@ -42,6 +44,7 @@ Name | Description --> ### Lookup plugins +Click on the lookup plugin name below, to get detailed documentation about it. Name | Description | Tests --- | --- | --- @@ -57,6 +60,7 @@ Name | Description | Tests [checkmk.general.version](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/version.py)|Look up version and edition information.|[![Integration Tests for Version Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml) ### Modules +Click on the module name below, to get detailed documentation about it. Name | Description | Tests --- | --- | --- @@ -74,6 +78,7 @@ Name | Description | Tests [checkmk.general.user](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/user.py)|Manage users.|[![Integration Tests for User Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml) ### Roles +Click on the role name below, to get documentation about the role. Name | Description | Tests --- | --- | --- From 5472f93a5a39bc817affc7ac71e079d16ff4c22c Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 11:27:19 -0500 Subject: [PATCH 38/49] Add dedicated README for lookup plugins. --- README.md | 1 + plugins/lookup/README.md | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 plugins/lookup/README.md diff --git a/README.md b/README.md index 498975512..4d2772925 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Name | Description ### Lookup plugins Click on the lookup plugin name below, to get detailed documentation about it. +For more in-depth documentation, see [this README](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/README.md). Name | Description | Tests --- | --- | --- diff --git a/plugins/lookup/README.md b/plugins/lookup/README.md new file mode 100644 index 000000000..c5b855619 --- /dev/null +++ b/plugins/lookup/README.md @@ -0,0 +1,57 @@ +# Lookup Plugins + +## Using variables for Lookup plugins +It is possible to set variables for authentication globally for lookup plugins. +This way, they do not need to be provided at task level. + +### Method 1: Environment variables +```bash +export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver" +export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite +export ANSIBLE_LOOKUP_AUTOMATION_USER=automation +export ANSIBLE_LOOKUP_AUTOMATION_SECRET=mysecret +export ANSIBLE_LOOKUP_VALIDATE_CERTS=False +``` + +### Method 2: In `ansible.cfg` +```ini +[checkmk_lookup] +server_url = https://myserver +site = mysite +automation_user = automation +automation_secret = mysecret +validate_certs = False + +``` + +### Method 3: In playbooks or the inventory +```yaml +- name: My Task + hosts: localhost + gather_facts: false + vars: + ansible_lookup_checkmk_server_url: "https://myserver" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_automation_user: "automation" + ansible_lookup_automation_secret: "mysecret" + ansible_lookup_validate_certs: false + + tasks: + - name: Get the attributes of myhost + ansible.builtin.debug: + msg: "Attributes of myhost: {{ attributes }}" + vars: + attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" +``` + +### Example +The following task will work, if one of the above methods has been applied. +```yaml +- name: My Task + tasks: + - name: Get the attributes of myhost + ansible.builtin.debug: + msg: "Attributes of myhost: {{ attributes }}" + vars: + attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" +``` From 607ed96c756111937dee783e8b9e92dc504c5a06 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 13:44:05 -0500 Subject: [PATCH 39/49] Add missing changelogs. --- changelogs/fragments/parents.yml | 5 +++++ changelogs/fragments/release_summary.yml | 2 +- changelogs/fragments/rule.yml | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/parents.yml create mode 100644 changelogs/fragments/rule.yml diff --git a/changelogs/fragments/parents.yml b/changelogs/fragments/parents.yml new file mode 100644 index 000000000..b979b09b5 --- /dev/null +++ b/changelogs/fragments/parents.yml @@ -0,0 +1,5 @@ +bugfixes: + - Host module - Parents will be parsed properly now. + This means, that parents given as a string will now be parsed as a list of one. + - Folder module - Parents will be parsed properly now. + This means, that parents given as a string will now be parsed as a list of one. diff --git a/changelogs/fragments/release_summary.yml b/changelogs/fragments/release_summary.yml index 61a046a26..378cdb716 100644 --- a/changelogs/fragments/release_summary.yml +++ b/changelogs/fragments/release_summary.yml @@ -1 +1 @@ -release_summary: "Folders, build related changed and the environment." +release_summary: "Reworking the CI, enhancing code quality and improving modules." diff --git a/changelogs/fragments/rule.yml b/changelogs/fragments/rule.yml new file mode 100644 index 000000000..03b6872ef --- /dev/null +++ b/changelogs/fragments/rule.yml @@ -0,0 +1,4 @@ +minor_changes: + - Rule module - Introduce rule_id to uniquely identify rules. + This ID can be retrieved e.g., using the lookup plugin. + Refer to the module documentation for further details. From 6289a5c7541285bcfd1ebca48a10d8481f776c6d Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 16 Feb 2024 14:25:40 -0500 Subject: [PATCH 40/49] Add missing changelog. --- changelogs/fragments/user.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/user.yml diff --git a/changelogs/fragments/user.yml b/changelogs/fragments/user.yml new file mode 100644 index 000000000..0d4ed82b5 --- /dev/null +++ b/changelogs/fragments/user.yml @@ -0,0 +1,2 @@ +bugfixes: + - User module - Fix bug, where an absent user was created, if 'reset_password' was used. From 15780c33925ec0fc9c8978ccb5a9bf29d67037a5 Mon Sep 17 00:00:00 2001 From: robin-checkmk <93658105+robin-checkmk@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:09:31 +0000 Subject: [PATCH 41/49] Update Docs and Changelogs upon Release --- CHANGELOG.rst | 28 ++++- changelogs/.plugin-cache.yaml | 8 +- .../4.3.0}/fix_folder_module_idempotency.yml | 0 .../{fragments => archive/4.3.0}/folder.yml | 0 .../{fragments => archive/4.3.0}/lookups.yml | 0 .../{fragments => archive/4.3.0}/parents.yml | 0 .../4.3.0}/release_summary.yml | 0 .../{fragments => archive/4.3.0}/rule.yml | 0 .../{fragments => archive/4.3.0}/user.yml | 0 changelogs/changelog.yaml | 35 ++++++ docs/activation_module.rst | 6 +- docs/bakery_lookup.rst | 111 ++++++++++++++-- docs/bakery_module.rst | 6 +- docs/contact_group_module.rst | 6 +- docs/discovery_module.rst | 6 +- docs/downtime_module.rst | 6 +- docs/environment_variables.rst | 78 +++++++++++- docs/folder_lookup.rst | 112 ++++++++++++++++- docs/folder_module.rst | 50 +++++++- docs/folders_lookup.rst | 119 +++++++++++++++++- docs/host_group_module.rst | 6 +- docs/host_lookup.rst | 112 ++++++++++++++++- docs/host_module.rst | 6 +- docs/hosts_lookup.rst | 119 +++++++++++++++++- docs/index.rst | 10 +- docs/password_module.rst | 6 +- docs/rule_lookup.rst | 114 ++++++++++++++++- docs/rule_module.rst | 50 +++++++- docs/rules_lookup.rst | 117 ++++++++++++++++- docs/ruleset_lookup.rst | 114 ++++++++++++++++- docs/rulesets_lookup.rst | 115 ++++++++++++++++- docs/service_group_module.rst | 6 +- docs/tag_group_module.rst | 6 +- docs/timeperiod_module.rst | 6 +- docs/user_module.rst | 6 +- docs/version_lookup.rst | 103 ++++++++++++++- 36 files changed, 1359 insertions(+), 108 deletions(-) rename changelogs/{fragments => archive/4.3.0}/fix_folder_module_idempotency.yml (100%) rename changelogs/{fragments => archive/4.3.0}/folder.yml (100%) rename changelogs/{fragments => archive/4.3.0}/lookups.yml (100%) rename changelogs/{fragments => archive/4.3.0}/parents.yml (100%) rename changelogs/{fragments => archive/4.3.0}/release_summary.yml (100%) rename changelogs/{fragments => archive/4.3.0}/rule.yml (100%) rename changelogs/{fragments => archive/4.3.0}/user.yml (100%) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ea37fcde..bcb2476d9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,33 @@ checkmk.general Release Notes .. contents:: Topics +v4.3.0 +====== + +Release Summary +--------------- + +Reworking the CI, enhancing code quality and improving modules. + +Minor Changes +------------- + +- Folder module - Extend attribute management. Please refer to the module documentation for more details. +- Lookup modules - Enable usage of ini files, environment and inventory variables to configure basic settings for the lookup plugins, like e.g., the server_url or site alongside the authentication options. Refer to the module documentation for details. +- Rule module - Introduce rule_id to uniquely identify rules. This ID can be retrieved e.g., using the lookup plugin. Refer to the module documentation for further details. + +Bugfixes +-------- + +- Folder module - Fix idempotency when using "attributes" parameter for creating a folder. +- Folder module - Parents will be parsed properly now. This means, that parents given as a string will now be parsed as a list of one. +- Host module - Parents will be parsed properly now. This means, that parents given as a string will now be parsed as a list of one. +- User module - Fix bug, where an absent user was created, if 'reset_password' was used. + +Known Issues +------------ + +- Lookup modules - When using inventory variables to configure e.g., the server_url, it is not possible to assign other variables to these variables. This is a limitation of Ansble itself. v4.2.0 ====== @@ -604,7 +631,6 @@ Major Changes Minor Changes ------------- - v0.12.0 ======= diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 5dbfd4d98..980e55b7f 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -31,15 +31,15 @@ plugins: name: hosts version_added: 3.3.0 rule: - description: Show rule + description: Show a rule name: rule version_added: 3.5.0 rules: - description: List rules + description: Get a list rules name: rules version_added: 3.5.0 ruleset: - description: Show ruleset + description: Show a ruleset name: ruleset version_added: 3.5.0 rulesets: @@ -126,4 +126,4 @@ plugins: strategy: {} test: {} vars: {} -version: 4.2.0 +version: 4.3.0 diff --git a/changelogs/fragments/fix_folder_module_idempotency.yml b/changelogs/archive/4.3.0/fix_folder_module_idempotency.yml similarity index 100% rename from changelogs/fragments/fix_folder_module_idempotency.yml rename to changelogs/archive/4.3.0/fix_folder_module_idempotency.yml diff --git a/changelogs/fragments/folder.yml b/changelogs/archive/4.3.0/folder.yml similarity index 100% rename from changelogs/fragments/folder.yml rename to changelogs/archive/4.3.0/folder.yml diff --git a/changelogs/fragments/lookups.yml b/changelogs/archive/4.3.0/lookups.yml similarity index 100% rename from changelogs/fragments/lookups.yml rename to changelogs/archive/4.3.0/lookups.yml diff --git a/changelogs/fragments/parents.yml b/changelogs/archive/4.3.0/parents.yml similarity index 100% rename from changelogs/fragments/parents.yml rename to changelogs/archive/4.3.0/parents.yml diff --git a/changelogs/fragments/release_summary.yml b/changelogs/archive/4.3.0/release_summary.yml similarity index 100% rename from changelogs/fragments/release_summary.yml rename to changelogs/archive/4.3.0/release_summary.yml diff --git a/changelogs/fragments/rule.yml b/changelogs/archive/4.3.0/rule.yml similarity index 100% rename from changelogs/fragments/rule.yml rename to changelogs/archive/4.3.0/rule.yml diff --git a/changelogs/fragments/user.yml b/changelogs/archive/4.3.0/user.yml similarity index 100% rename from changelogs/fragments/user.yml rename to changelogs/archive/4.3.0/user.yml diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 27a17b96a..ae2f95745 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -823,3 +823,38 @@ releases: - tag_group.yml - user.yml release_date: '2024-01-23' + 4.3.0: + changes: + bugfixes: + - Folder module - Fix idempotency when using "attributes" parameter for creating + a folder. + - Folder module - Parents will be parsed properly now. This means, that parents + given as a string will now be parsed as a list of one. + - Host module - Parents will be parsed properly now. This means, that parents + given as a string will now be parsed as a list of one. + - User module - Fix bug, where an absent user was created, if 'reset_password' + was used. + known_issues: + - Lookup modules - When using inventory variables to configure e.g., the server_url, + it is not possible to assign other variables to these variables. This is a + limitation of Ansble itself. + minor_changes: + - Folder module - Extend attribute management. Please refer to the module documentation + for more details. + - Lookup modules - Enable usage of ini files, environment and inventory variables + to configure basic settings for the lookup plugins, like e.g., the server_url + or site alongside the authentication options. Refer to the module documentation + for details. + - Rule module - Introduce rule_id to uniquely identify rules. This ID can be + retrieved e.g., using the lookup plugin. Refer to the module documentation + for further details. + release_summary: Reworking the CI, enhancing code quality and improving modules. + fragments: + - fix_folder_module_idempotency.yml + - folder.yml + - lookups.yml + - parents.yml + - release_summary.yml + - rule.yml + - user.yml + release_date: '2024-02-16' diff --git a/docs/activation_module.rst b/docs/activation_module.rst index 833b227a3..f3e352620 100644 --- a/docs/activation_module.rst +++ b/docs/activation_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.activation module -- Activate changes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -259,7 +259,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/bakery_lookup.rst b/docs/bakery_lookup.rst index 5aaac065f..13946203f 100644 --- a/docs/bakery_lookup.rst +++ b/docs/bakery_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.bakery lookup -- Get the bakery status of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -112,7 +112,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -149,7 +166,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -189,6 +223,23 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -223,7 +274,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -260,7 +328,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- Wether or not to validate TLS certificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -271,6 +339,23 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -288,6 +373,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -301,7 +387,7 @@ Examples - name: "Show bakery status" - debug: + ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: bakery: "{{ lookup('checkmk.general.bakery', @@ -312,6 +398,17 @@ Examples automation_secret=automation_secret )}}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Bakery status is {{ bakery }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + bakery: "{{ lookup('checkmk.general.bakery') }}" + diff --git a/docs/bakery_module.rst b/docs/bakery_module.rst index e67c155e1..14a417862 100644 --- a/docs/bakery_module.rst +++ b/docs/bakery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.bakery module -- Trigger baking and signing in the agent bakery. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -174,7 +174,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/contact_group_module.rst b/docs/contact_group_module.rst index e8c39b575..be1e21f0c 100644 --- a/docs/contact_group_module.rst +++ b/docs/contact_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.contact_group module -- Manage contact groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/discovery_module.rst b/docs/discovery_module.rst index 41290fe02..edcd49017 100644 --- a/docs/discovery_module.rst +++ b/docs/discovery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.discovery module -- Discover services in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -368,7 +368,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/downtime_module.rst b/docs/downtime_module.rst index 71133f598..04a9abcca 100644 --- a/docs/downtime_module.rst +++ b/docs/downtime_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.downtime module -- Manage downtimes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -402,7 +402,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst index e7b90605a..d0d332eb1 100644 --- a/docs/environment_variables.rst +++ b/docs/environment_variables.rst @@ -2,7 +2,7 @@ :orphan: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. _list_of_collection_env_vars: @@ -12,4 +12,78 @@ Index of all Collection Environment Variables The following index documents all environment variables declared by plugins in collections. Environment variables used by the ansible-core configuration are documented in :ref:`ansible_configuration_settings`. -No environment variables have been defined. +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET + + Automation secret for the REST API access. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER + + Automation user for the REST API access. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_SERVER_URL + + See the documentations for the options where this environment variable is used. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_SITE + + Site name. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS + + Whether or not to validate TLS certificates. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` diff --git a/docs/folder_lookup.rst b/docs/folder_lookup.rst index 59945519e..3233819fb 100644 --- a/docs/folder_lookup.rst +++ b/docs/folder_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folder lookup -- Get folder attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -167,7 +167,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -204,7 +221,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -244,6 +278,23 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -278,7 +329,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -315,7 +383,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- Wether or not to validate TLS certificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -326,6 +394,23 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -342,6 +427,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.folder', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.folder', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -369,6 +458,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of folder /network: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" + diff --git a/docs/folder_module.rst b/docs/folder_module.rst index 2c3d68992..ec27bc4d3 100644 --- a/docs/folder_module.rst +++ b/docs/folder_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folder module -- Manage folders in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -177,6 +177,48 @@ Parameters The automation user you want to use. It has to be an 'Automation' user, not a normal one. + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.folder_module__parameter-extended_functionality: + + .. rst-class:: ansible-option-title + + **extended_functionality** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Allow extended functionality instead of the expected REST API behavior. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + .. raw:: html
@@ -280,7 +322,7 @@ Parameters
- The remove\_attributes of your host as described in the API documentation. This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The remove\_attributes of your host as described in the API documentation. \ :strong:`If a list of strings is supplied, the listed attributes are removed.`\ \ :strong:`If extended\_functionality and a dict is supplied, the attributes that exactly match the passed attributes are removed.`\ This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. .. raw:: html @@ -314,7 +356,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/folders_lookup.rst b/docs/folders_lookup.rst index 243c341ba..cf46723a7 100644 --- a/docs/folders_lookup.rst +++ b/docs/folders_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folders lookup -- Get various information about a folder .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -168,7 +168,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -205,7 +222,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -290,6 +324,23 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -369,7 +420,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -406,7 +474,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -417,6 +485,23 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -433,6 +518,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.folders', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.folders', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -483,6 +572,24 @@ Examples loop_control: label: "{{ item.0.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Folder tree: {{ item.id }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.folders', + '~', + show_hosts=False, + recursive=True, + ) }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/host_group_module.rst b/docs/host_group_module.rst index 31633c1ce..00fcf6893 100644 --- a/docs/host_group_module.rst +++ b/docs/host_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host_group module -- Manage host groups in Checkmk (bulk version .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/host_lookup.rst b/docs/host_lookup.rst index 306a3a4dc..20df10c55 100644 --- a/docs/host_lookup.rst +++ b/docs/host_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host lookup -- Get host attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -167,7 +167,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -204,7 +221,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -289,6 +323,23 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -323,7 +374,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -360,7 +428,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -371,6 +439,23 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -387,6 +472,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.host', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.host', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -415,6 +504,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of host example: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}" + diff --git a/docs/host_module.rst b/docs/host_module.rst index c0b8a4510..8e699fcec 100644 --- a/docs/host_module.rst +++ b/docs/host_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host module -- Manage hosts in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -318,7 +318,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/hosts_lookup.rst b/docs/hosts_lookup.rst index cdb4f881c..444d3e617 100644 --- a/docs/hosts_lookup.rst +++ b/docs/hosts_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.hosts lookup -- Get various information about a host .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -113,7 +113,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -150,7 +167,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -235,6 +269,23 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -269,7 +320,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -306,7 +374,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -317,6 +385,23 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -327,6 +412,14 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -355,6 +448,20 @@ Examples loop_control: label: "{{ item.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.hosts', effective_attributes=True) }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/index.rst b/docs/index.rst index 9e4033ad8..6fa6c5930 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. _plugins_in_checkmk.general: @@ -9,7 +9,7 @@ Checkmk.General =============== -Collection version 4.2.0 +Collection version 4.3.0 .. contents:: :local: @@ -99,9 +99,9 @@ Lookup Plugins * :ansplugin:`folders lookup ` -- Get various information about a folder * :ansplugin:`host lookup ` -- Get host attributes * :ansplugin:`hosts lookup ` -- Get various information about a host -* :ansplugin:`rule lookup ` -- Show rule -* :ansplugin:`rules lookup ` -- List rules -* :ansplugin:`ruleset lookup ` -- Show ruleset +* :ansplugin:`rule lookup ` -- Show a rule +* :ansplugin:`rules lookup ` -- Get a list rules +* :ansplugin:`ruleset lookup ` -- Show a ruleset * :ansplugin:`rulesets lookup ` -- Search rulesets * :ansplugin:`version lookup ` -- Get the version of a Checkmk server diff --git a/docs/password_module.rst b/docs/password_module.rst index 3768602a1..e0b8634e0 100644 --- a/docs/password_module.rst +++ b/docs/password_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.password module -- Manage passwords in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -378,7 +378,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/rule_lookup.rst b/docs/rule_lookup.rst index 9c3651195..b32c830f7 100644 --- a/docs/rule_lookup.rst +++ b/docs/rule_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.rule lookup -- Show rule -++++++++++++++++++++++++++++++++++++++++ +checkmk.general.rule lookup -- Show a rule +++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -226,6 +260,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -263,6 +314,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -297,7 +365,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -308,6 +376,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -318,6 +403,14 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -345,6 +438,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}" + diff --git a/docs/rule_module.rst b/docs/rule_module.rst index bd973c7bd..9fa3ca7e2 100644 --- a/docs/rule_module.rst +++ b/docs/rule_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.rule module -- Manage rules in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -461,6 +461,50 @@ Parameters Properties of the rule. + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__parameter-rule/rule_id: + + .. rst-class:: ansible-option-title + + **rule_id** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + If given, it will be \ :literal:`the only condition`\ to identify the rule to work on. + + When there's no rule found with this id, the task will fail. + + .. raw:: html
@@ -569,7 +613,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/rules_lookup.rst b/docs/rules_lookup.rst index 65409420e..285e5b5dc 100644 --- a/docs/rules_lookup.rst +++ b/docs/rules_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.rules lookup -- List rules -++++++++++++++++++++++++++++++++++++++++++ +checkmk.general.rules lookup -- Get a list rules +++++++++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -308,6 +342,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -345,6 +396,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -379,7 +447,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -390,6 +458,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -400,6 +485,14 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -446,6 +539,20 @@ Examples loop_control: label: "{{ item.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rules', ruleset='host_groups') }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/ruleset_lookup.rst b/docs/ruleset_lookup.rst index 5d0df3cb3..544918bba 100644 --- a/docs/ruleset_lookup.rst +++ b/docs/ruleset_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.ruleset lookup -- Show ruleset -++++++++++++++++++++++++++++++++++++++++++++++ +checkmk.general.ruleset lookup -- Show a ruleset +++++++++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -226,6 +260,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -263,6 +314,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -297,7 +365,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -308,6 +376,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -318,6 +403,14 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -345,6 +438,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}" + diff --git a/docs/rulesets_lookup.rst b/docs/rulesets_lookup.rst index 3c1850bac..b8b0cbf81 100644 --- a/docs/rulesets_lookup.rst +++ b/docs/rulesets_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.rulesets lookup -- Search rulesets .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -359,6 +393,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -393,7 +444,24 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)``
- Site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -430,7 +498,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)``
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -441,6 +509,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -451,6 +536,14 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -498,6 +591,20 @@ Examples loop_control: label: "{{ item.0.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset {{ item.extension.name }} is deprecated." + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" + loop_control: + label: "{{ item.0.id }}" + diff --git a/docs/service_group_module.rst b/docs/service_group_module.rst index 23823acc0..ff0d1a444 100644 --- a/docs/service_group_module.rst +++ b/docs/service_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.service_group module -- Manage service groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/tag_group_module.rst b/docs/tag_group_module.rst index 474bac84c..b04875a73 100644 --- a/docs/tag_group_module.rst +++ b/docs/tag_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.tag_group module -- Manage tag groups in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -292,7 +292,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/timeperiod_module.rst b/docs/timeperiod_module.rst index 42d060689..1666e6506 100644 --- a/docs/timeperiod_module.rst +++ b/docs/timeperiod_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.timeperiod module -- Manage time periods in checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -344,7 +344,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/user_module.rst b/docs/user_module.rst index 5ec6d55ce..9fb54be1b 100644 --- a/docs/user_module.rst +++ b/docs/user_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.user module -- Manage users in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -975,7 +975,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/version_lookup.rst b/docs/version_lookup.rst index 7f592e844..60024fa81 100644 --- a/docs/version_lookup.rst +++ b/docs/version_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.version lookup -- Get the version of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -186,7 +220,24 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a
- URL of the Checkmk server + URL of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url .. raw:: html @@ -226,6 +277,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -271,6 +339,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -288,6 +373,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -311,6 +397,17 @@ Examples automation_secret=my_secret )}}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Server version is {{ version }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.version') }}" + From b449a5beeb9e9142ded1c5ea21c6195e79f455fd Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 19 Feb 2024 14:09:40 -0500 Subject: [PATCH 42/49] Bugfix bakery integration tests. --- tests/integration/targets/bakery/tasks/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration/targets/bakery/tasks/main.yml b/tests/integration/targets/bakery/tasks/main.yml index bbb3963bc..de3aba5ec 100644 --- a/tests/integration/targets/bakery/tasks/main.yml +++ b/tests/integration/targets/bakery/tasks/main.yml @@ -5,6 +5,16 @@ - name: "Run Preparations." ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml +- name: "Inject a Key into the Sites." # This is a hack and should never be done in production! + ansible.builtin.copy: + src: agent_signature_keys.mk + dest: "/omd/sites/{{ item.site }}/etc/check_mk/multisite.d/wato/agent_signature_keys.mk" + owner: "{{ item.site }}" + group: "{{ item.site }}" + mode: "0660" + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" + - name: "Testing." ansible.builtin.include_tasks: test.yml loop: "{{ test_sites }}" From ad44786ddf5680cd6937ab363b52c72e15c53885 Mon Sep 17 00:00:00 2001 From: Mik3yZ Date: Tue, 20 Feb 2024 17:04:34 +0100 Subject: [PATCH 43/49] Update rule.py rule.py always overwrites rule["conditions"] when conditions are given, and doesn't fill it with an empty dict when no conditions are given --- plugins/modules/rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index a446c98a2..238dbd8cd 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -583,7 +583,7 @@ def run_module(): if not rule.get("value_raw"): exit_failed(module, "Rule value_raw is required") # Default to all hosts if conditions arent given - if rule.get("conditions"): + if not rule.get("conditions"): rule["conditions"] = { "host_tags": [], "host_labels": [], From ebbc087882cceb3cca7f396ddd95b4fcdbd5b80b Mon Sep 17 00:00:00 2001 From: Mik3yZ Date: Wed, 21 Feb 2024 10:00:11 +0100 Subject: [PATCH 44/49] Create fix_rule_conditions_missing.yml --- changelogs/fragments/fix_rule_conditions_missing.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/fix_rule_conditions_missing.yml diff --git a/changelogs/fragments/fix_rule_conditions_missing.yml b/changelogs/fragments/fix_rule_conditions_missing.yml new file mode 100644 index 000000000..341b85838 --- /dev/null +++ b/changelogs/fragments/fix_rule_conditions_missing.yml @@ -0,0 +1,2 @@ +bugfixes: + - Rule module - Fix empty rule conditions. From 3a031c984553fd165c5848326d020476acb5bda1 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Wed, 21 Feb 2024 08:26:44 -0500 Subject: [PATCH 45/49] Bump collection version. --- SUPPORT.md | 1 + galaxy.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SUPPORT.md b/SUPPORT.md index 8700749a5..0cfd59c95 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -50,3 +50,4 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 4.1.0 | 2.0.0p39, 2.1.0p37, 2.2.0p17 | 2.14, 2.15, 2.16 | None 4.2.0 | 2.0.0p39, 2.1.0p38, 2.2.0p19 | 2.14, 2.15, 2.16 | None 4.3.0 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None +4.3.1 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None diff --git a/galaxy.yml b/galaxy.yml index 028a6ee41..f4f35b8cd 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ name: general # The version of the collection. Must be compatible with semantic versioning -version: 4.3.0 +version: 4.3.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md From a1d8c357ed6c91df8e4e2303b73f93d9f63be2b2 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Wed, 21 Feb 2024 08:28:35 -0500 Subject: [PATCH 46/49] Add release summary. --- changelogs/fragments/release_summary.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/fragments/release_summary.yml diff --git a/changelogs/fragments/release_summary.yml b/changelogs/fragments/release_summary.yml new file mode 100644 index 000000000..b345fa2b5 --- /dev/null +++ b/changelogs/fragments/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Bugfix Release." From 717f306e766c0414ea37052e1429078fd98b66d7 Mon Sep 17 00:00:00 2001 From: robin-checkmk <93658105+robin-checkmk@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:51:15 +0000 Subject: [PATCH 47/49] Update Docs and Changelogs upon Release --- CHANGELOG.rst | 13 +++++++++++++ changelogs/.plugin-cache.yaml | 2 +- .../4.3.1}/fix_rule_conditions_missing.yml | 0 .../4.3.1}/release_summary.yml | 0 changelogs/changelog.yaml | 9 +++++++++ docs/activation_module.rst | 2 +- docs/bakery_lookup.rst | 2 +- docs/bakery_module.rst | 2 +- docs/contact_group_module.rst | 2 +- docs/discovery_module.rst | 2 +- docs/downtime_module.rst | 2 +- docs/folder_lookup.rst | 2 +- docs/folder_module.rst | 2 +- docs/folders_lookup.rst | 2 +- docs/host_group_module.rst | 2 +- docs/host_lookup.rst | 2 +- docs/host_module.rst | 2 +- docs/hosts_lookup.rst | 2 +- docs/index.rst | 2 +- docs/password_module.rst | 2 +- docs/rule_lookup.rst | 2 +- docs/rule_module.rst | 2 +- docs/rules_lookup.rst | 2 +- docs/ruleset_lookup.rst | 2 +- docs/rulesets_lookup.rst | 2 +- docs/service_group_module.rst | 2 +- docs/tag_group_module.rst | 2 +- docs/timeperiod_module.rst | 2 +- docs/user_module.rst | 2 +- docs/version_lookup.rst | 2 +- 30 files changed, 48 insertions(+), 26 deletions(-) rename changelogs/{fragments => archive/4.3.1}/fix_rule_conditions_missing.yml (100%) rename changelogs/{fragments => archive/4.3.1}/release_summary.yml (100%) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bcb2476d9..3ad55d034 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,19 @@ checkmk.general Release Notes .. contents:: Topics +v4.3.1 +====== + +Release Summary +--------------- + +Bugfix Release. + +Bugfixes +-------- + +- Rule module - Fix empty rule conditions. + v4.3.0 ====== diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 980e55b7f..eca74aa33 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -126,4 +126,4 @@ plugins: strategy: {} test: {} vars: {} -version: 4.3.0 +version: 4.3.1 diff --git a/changelogs/fragments/fix_rule_conditions_missing.yml b/changelogs/archive/4.3.1/fix_rule_conditions_missing.yml similarity index 100% rename from changelogs/fragments/fix_rule_conditions_missing.yml rename to changelogs/archive/4.3.1/fix_rule_conditions_missing.yml diff --git a/changelogs/fragments/release_summary.yml b/changelogs/archive/4.3.1/release_summary.yml similarity index 100% rename from changelogs/fragments/release_summary.yml rename to changelogs/archive/4.3.1/release_summary.yml diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ae2f95745..f4e51c674 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -858,3 +858,12 @@ releases: - rule.yml - user.yml release_date: '2024-02-16' + 4.3.1: + changes: + bugfixes: + - Rule module - Fix empty rule conditions. + release_summary: Bugfix Release. + fragments: + - fix_rule_conditions_missing.yml + - release_summary.yml + release_date: '2024-02-21' diff --git a/docs/activation_module.rst b/docs/activation_module.rst index f3e352620..1897e6e4c 100644 --- a/docs/activation_module.rst +++ b/docs/activation_module.rst @@ -23,7 +23,7 @@ checkmk.general.activation module -- Activate changes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/bakery_lookup.rst b/docs/bakery_lookup.rst index 13946203f..520f10543 100644 --- a/docs/bakery_lookup.rst +++ b/docs/bakery_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.bakery lookup -- Get the bakery status of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/bakery_module.rst b/docs/bakery_module.rst index 14a417862..796e6b8dc 100644 --- a/docs/bakery_module.rst +++ b/docs/bakery_module.rst @@ -23,7 +23,7 @@ checkmk.general.bakery module -- Trigger baking and signing in the agent bakery. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/contact_group_module.rst b/docs/contact_group_module.rst index be1e21f0c..87507af6e 100644 --- a/docs/contact_group_module.rst +++ b/docs/contact_group_module.rst @@ -23,7 +23,7 @@ checkmk.general.contact_group module -- Manage contact groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/discovery_module.rst b/docs/discovery_module.rst index edcd49017..ce3148de8 100644 --- a/docs/discovery_module.rst +++ b/docs/discovery_module.rst @@ -23,7 +23,7 @@ checkmk.general.discovery module -- Discover services in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/downtime_module.rst b/docs/downtime_module.rst index 04a9abcca..7d608a674 100644 --- a/docs/downtime_module.rst +++ b/docs/downtime_module.rst @@ -23,7 +23,7 @@ checkmk.general.downtime module -- Manage downtimes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/folder_lookup.rst b/docs/folder_lookup.rst index 3233819fb..bd263439a 100644 --- a/docs/folder_lookup.rst +++ b/docs/folder_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.folder lookup -- Get folder attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/folder_module.rst b/docs/folder_module.rst index ec27bc4d3..5152810c9 100644 --- a/docs/folder_module.rst +++ b/docs/folder_module.rst @@ -23,7 +23,7 @@ checkmk.general.folder module -- Manage folders in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/folders_lookup.rst b/docs/folders_lookup.rst index cf46723a7..1db6b14c1 100644 --- a/docs/folders_lookup.rst +++ b/docs/folders_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.folders lookup -- Get various information about a folder .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/host_group_module.rst b/docs/host_group_module.rst index 00fcf6893..58adb75b1 100644 --- a/docs/host_group_module.rst +++ b/docs/host_group_module.rst @@ -23,7 +23,7 @@ checkmk.general.host_group module -- Manage host groups in Checkmk (bulk version .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/host_lookup.rst b/docs/host_lookup.rst index 20df10c55..49035dad6 100644 --- a/docs/host_lookup.rst +++ b/docs/host_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.host lookup -- Get host attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/host_module.rst b/docs/host_module.rst index 8e699fcec..304716015 100644 --- a/docs/host_module.rst +++ b/docs/host_module.rst @@ -23,7 +23,7 @@ checkmk.general.host module -- Manage hosts in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/hosts_lookup.rst b/docs/hosts_lookup.rst index 444d3e617..a4d661577 100644 --- a/docs/hosts_lookup.rst +++ b/docs/hosts_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.hosts lookup -- Get various information about a host .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/index.rst b/docs/index.rst index 6fa6c5930..20fc5af31 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Checkmk.General =============== -Collection version 4.3.0 +Collection version 4.3.1 .. contents:: :local: diff --git a/docs/password_module.rst b/docs/password_module.rst index e0b8634e0..f3c4a3010 100644 --- a/docs/password_module.rst +++ b/docs/password_module.rst @@ -23,7 +23,7 @@ checkmk.general.password module -- Manage passwords in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/rule_lookup.rst b/docs/rule_lookup.rst index b32c830f7..2f1740416 100644 --- a/docs/rule_lookup.rst +++ b/docs/rule_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.rule lookup -- Show a rule .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/rule_module.rst b/docs/rule_module.rst index 9fa3ca7e2..58a670819 100644 --- a/docs/rule_module.rst +++ b/docs/rule_module.rst @@ -23,7 +23,7 @@ checkmk.general.rule module -- Manage rules in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/rules_lookup.rst b/docs/rules_lookup.rst index 285e5b5dc..ce6b14b53 100644 --- a/docs/rules_lookup.rst +++ b/docs/rules_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.rules lookup -- Get a list rules .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/ruleset_lookup.rst b/docs/ruleset_lookup.rst index 544918bba..2868af97d 100644 --- a/docs/ruleset_lookup.rst +++ b/docs/ruleset_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.ruleset lookup -- Show a ruleset .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/rulesets_lookup.rst b/docs/rulesets_lookup.rst index b8b0cbf81..71febe03e 100644 --- a/docs/rulesets_lookup.rst +++ b/docs/rulesets_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.rulesets lookup -- Search rulesets .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/service_group_module.rst b/docs/service_group_module.rst index ff0d1a444..248ca372e 100644 --- a/docs/service_group_module.rst +++ b/docs/service_group_module.rst @@ -23,7 +23,7 @@ checkmk.general.service_group module -- Manage service groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/tag_group_module.rst b/docs/tag_group_module.rst index b04875a73..441a63269 100644 --- a/docs/tag_group_module.rst +++ b/docs/tag_group_module.rst @@ -23,7 +23,7 @@ checkmk.general.tag_group module -- Manage tag groups in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/timeperiod_module.rst b/docs/timeperiod_module.rst index 1666e6506..11c8938eb 100644 --- a/docs/timeperiod_module.rst +++ b/docs/timeperiod_module.rst @@ -23,7 +23,7 @@ checkmk.general.timeperiod module -- Manage time periods in checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/user_module.rst b/docs/user_module.rst index 9fb54be1b..cd72f8c1d 100644 --- a/docs/user_module.rst +++ b/docs/user_module.rst @@ -23,7 +23,7 @@ checkmk.general.user module -- Manage users in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.3.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/version_lookup.rst b/docs/version_lookup.rst index 60024fa81..7d815c5a4 100644 --- a/docs/version_lookup.rst +++ b/docs/version_lookup.rst @@ -23,7 +23,7 @@ checkmk.general.version lookup -- Get the version of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. From 2c5256f7639547e0427452017ad390633f4e6fc6 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 5 Mar 2024 15:26:35 -0500 Subject: [PATCH 48/49] Bump Checkmk versions. --- roles/agent/README.md | 2 +- roles/agent/defaults/main.yml | 2 +- roles/agent/molecule/2.1.0/group_vars/all.yml | 2 +- roles/agent/molecule/2.2.0/group_vars/all.yml | 2 +- roles/server/README.md | 2 +- roles/server/defaults/main.yml | 2 +- roles/server/molecule/2.1.0/group_vars/all.yml | 2 +- roles/server/molecule/2.2.0/group_vars/all.yml | 2 +- scripts/release.sh | 4 ++-- tests/integration/targets/activation/vars/main.yml | 6 +++--- tests/integration/targets/bakery/vars/main.yml | 4 ++-- tests/integration/targets/contact_group/vars/main.yml | 6 +++--- tests/integration/targets/discovery/vars/main.yml | 6 +++--- tests/integration/targets/downtime/vars/main.yml | 6 +++--- tests/integration/targets/folder/vars/main.yml | 6 +++--- tests/integration/targets/host/vars/main.yml | 6 +++--- tests/integration/targets/host_group/vars/main.yml | 8 ++++---- tests/integration/targets/lookup_bakery/vars/main.yml | 4 ++-- tests/integration/targets/lookup_folder/vars/main.yml | 6 +++--- tests/integration/targets/lookup_folders/vars/main.yml | 6 +++--- tests/integration/targets/lookup_host/vars/main.yml | 6 +++--- tests/integration/targets/lookup_hosts/vars/main.yml | 6 +++--- tests/integration/targets/lookup_rules/vars/main.yml | 6 +++--- tests/integration/targets/lookup_rulesets/vars/main.yml | 6 +++--- tests/integration/targets/lookup_version/vars/main.yml | 6 +++--- tests/integration/targets/password/vars/main.yml | 8 ++++---- tests/integration/targets/rule/vars/main.yml | 6 +++--- tests/integration/targets/service_group/vars/main.yml | 8 ++++---- tests/integration/targets/tag_group/vars/main.yml | 8 ++++---- tests/integration/targets/timeperiod/vars/main.yml | 6 +++--- tests/integration/targets/user/vars/main.yml | 8 ++++---- 31 files changed, 79 insertions(+), 79 deletions(-) diff --git a/roles/agent/README.md b/roles/agent/README.md index cb7d55538..1d28cd07f 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -13,7 +13,7 @@ It can be installed as easy as running: ## Role Variables - checkmk_agent_version: "2.2.0p22" + checkmk_agent_version: "2.2.0p23" The Checkmk version of the site your agents will talk to. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index d99c3a1f1..e43d0f13a 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_version: "2.2.0p22" +checkmk_agent_version: "2.2.0p23" checkmk_agent_edition: cre checkmk_agent_server_protocol: http checkmk_agent_server: localhost diff --git a/roles/agent/molecule/2.1.0/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index 23df43011..1437d561b 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p39" +checkmk_var_version: "2.1.0p40" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/agent/molecule/2.2.0/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index 2d9a1d6d6..6a8503c5c 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p22" +checkmk_var_version: "2.2.0p23" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/server/README.md b/roles/server/README.md index 3d679da43..f4e69f6aa 100644 --- a/roles/server/README.md +++ b/roles/server/README.md @@ -25,7 +25,7 @@ To learn about the distributions used in automated tests, inspect the correspond ## Role Variables - checkmk_server_version: "2.2.0p22" + checkmk_server_version: "2.2.0p23" The global Checkmk version. This is used for installing Checkmk. To manage sites and their version, see `checkmk_server_sites`. diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 62e6dd721..a7a084093 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -24,7 +24,7 @@ checkmk_server_server_stable_os: - Ubuntu-20 - Ubuntu-22 -checkmk_server_version: "2.2.0p22" +checkmk_server_version: "2.2.0p23" checkmk_server_edition: cre checkmk_server_verify_setup: 'true' diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index 8baa9a637..62c495f0e 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p39" +checkmk_var_version: "2.1.0p40" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/molecule/2.2.0/group_vars/all.yml b/roles/server/molecule/2.2.0/group_vars/all.yml index 902bdc3ae..a65cf8c29 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p22" +checkmk_var_version: "2.2.0p23" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/scripts/release.sh b/scripts/release.sh index 328c6b1a4..6342e3fc8 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,8 +16,8 @@ collection_dir="${script_dir%/*}" # Update these as necessary: checkmk_ancient="2.0.0p39" -checkmk_oldstable="2.1.0p39" -checkmk_stable="2.2.0p22" +checkmk_oldstable="2.1.0p40" +checkmk_stable="2.2.0p23" while getopts 's:t:' OPTION; do case "$OPTION" in diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index f55a7fb56..91e8ed7ad 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index f390261b6..2d72d28d5 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index 124c01d29..f851cd39c 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index 53e43630a..34512dca5 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index f55a7fb56..91e8ed7ad 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 30d015abd..798d8fdf1 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index 239cd82ac..c1cff38fa 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index f6facb348..ea40fab2c 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_bakery/vars/main.yml b/tests/integration/targets/lookup_bakery/vars/main.yml index 3809fd273..bddbccdff 100644 --- a/tests/integration/targets/lookup_bakery/vars/main.yml +++ b/tests/integration/targets/lookup_bakery/vars/main.yml @@ -1,8 +1,8 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index 6fed2d247..46475a44b 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index f838892b0..e738dac4b 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index 3b5e6be7f..cd18b47b3 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index c370444f5..6b443cd28 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_rules/vars/main.yml b/tests/integration/targets/lookup_rules/vars/main.yml index 5f85c1230..10c7b2387 100644 --- a/tests/integration/targets/lookup_rules/vars/main.yml +++ b/tests/integration/targets/lookup_rules/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_rulesets/vars/main.yml b/tests/integration/targets/lookup_rulesets/vars/main.yml index cef6b9a8a..497ef4d06 100644 --- a/tests/integration/targets/lookup_rulesets/vars/main.yml +++ b/tests/integration/targets/lookup_rulesets/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index a622b3980..12e5f3e2d 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index ad69bd9f9..b61b76dd1 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 9a019eb6e..cee5dc35d 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index 7b7b69f17..69dd7d45a 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index c8cd69b17..2f9a970df 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index 58d8a131b..2f1fe09fb 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 3da150a1c..40e3cb361 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -1,15 +1,15 @@ --- test_sites: - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" From 7ea95c74296a330293ab48a0db1b49a39eac1583 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 06:28:48 +0000 Subject: [PATCH 49/49] Bump softprops/action-gh-release from 1 to 2 Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fc6e7a3b3..c8ad39b7b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,7 @@ jobs: - name: Create Release and upload Assets id: create-release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }} draft: false