diff --git a/.gitignore b/.gitignore index cbf6858b8..765803282 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ tribe29-checkmk-*.tar.gz checkmk-general-*.tar.gz .vagrant/ +.tox/ build/ tests/output playbooks/vars/config.yml @@ -12,4 +13,5 @@ playbooks/test*.yml playbooks/hosts playbooks/hosts.bak Vagrantfile -Vagrantfile.bak \ No newline at end of file +Vagrantfile.bak +venv \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ea86fe113..d7e8e5a3b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,40 @@ checkmk.general Release Notes .. contents:: Topics +v5.0.0 +====== + +Release Summary +--------------- + +(Re)writing history with overhauled modules and updated Checkmk, Ansible, Distribution and Python support. + +Major Changes +------------- + +- Discovery module - The module now fully supports Checkmk 2.3.0. Additionally, two new parameters were introduced, `update_service_labels` and `monitor_undecided_services`. Refer to the module documentation for further details. +- Rule module - The complete module was rewritten to use the new module API. Additionally, a parameter "rule_id" was introduced to modify existing rules. Refer to the module documentation for further details. + +Minor Changes +------------- + +- Agent role - Add support to open firewall for a list of IPs. +- Agent role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. +- Server role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. +- Several modules - Remove unnecessary HTTP codes which get already imported via utils.py. +- Testing - Add Ansible 2.17 to all tests. Be advised, that this Ansible release drops support for Python 2.7 and 3.6. +- Testing - Add Ubuntu 24.04 to the Molecule tests. +- Testing - All tests now cover Checkmk 2.3.0. +- Testing - Remove Ansible 2.14 from all tests, as it is EOL. +- Testing - Remove Checkmk 2.0.0 from all tests, as it is EOL. +- Testing - The Molecule tests now run on Ubuntu 22.04. + +Breaking Changes / Porting Guide +-------------------------------- + +- Agent role - Not really a breaking change, but we removed the internal variable `checkmk_agent_server_ip`. If you set this variable in your inventory, please make sure to update your configuration accordingly! +- Folder lookup module - Return the complete folder information, not only the extensions. To keep the current behavior in your playbooks, you want to use `{{ my_lookup_result.extensions }}` instead of `{{ my_lookup_result }}`. + v4.4.1 ====== diff --git a/SUPPORT.md b/SUPPORT.md index b2baac345..69c5e1e31 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -53,4 +53,4 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 4.3.1 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None 4.4.0 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None 4.4.1 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None -5.0.0 | 2.1.0p43, 2.2.0p26, 2.3.0p3 | 2.15, 2.16, 2.17 | Breaking changes to the following modules: `lookup_folder`, `rule`. +5.0.0 | 2.1.0p44, 2.2.0p27, 2.3.0p5 | 2.15, 2.16, 2.17 | Breaking changes to the following modules: `lookup_folder`, `rule` and role: `agent`. diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index ffee32c0f..4248df3eb 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -126,4 +126,4 @@ plugins: strategy: {} test: {} vars: {} -version: 4.4.1 +version: 5.0.0 diff --git a/changelogs/archive/5.0.0/agent.yml b/changelogs/archive/5.0.0/agent.yml new file mode 100644 index 000000000..03b97ca76 --- /dev/null +++ b/changelogs/archive/5.0.0/agent.yml @@ -0,0 +1,6 @@ +minor_changes: + - Agent role - Add support to open firewall for a list of IPs. + +breaking_changes: + - Agent role - Not really a breaking change, but we removed the internal variable `checkmk_agent_server_ip`. + If you set this variable in your inventory, please make sure to update your configuration accordingly! diff --git a/changelogs/fragments/build.yml b/changelogs/archive/5.0.0/build.yml similarity index 70% rename from changelogs/fragments/build.yml rename to changelogs/archive/5.0.0/build.yml index 5780019fc..81f05ba54 100644 --- a/changelogs/fragments/build.yml +++ b/changelogs/archive/5.0.0/build.yml @@ -4,3 +4,5 @@ minor_changes: - Testing - The Molecule tests now run on Ubuntu 22.04. - Testing - Add Ubuntu 24.04 to the Molecule tests. - Testing - Remove Ansible 2.14 from all tests, as it is EOL. + - Testing - Add Ansible 2.17 to all tests. + Be advised, that this Ansible release drops support for Python 2.7 and 3.6. diff --git a/changelogs/archive/5.0.0/discovery.yml b/changelogs/archive/5.0.0/discovery.yml new file mode 100644 index 000000000..9640372bc --- /dev/null +++ b/changelogs/archive/5.0.0/discovery.yml @@ -0,0 +1,4 @@ +major_changes: + - Discovery module - The module now fully supports Checkmk 2.3.0. + Additionally, two new parameters were introduced, `update_service_labels` and `monitor_undecided_services`. + Refer to the module documentation for further details. diff --git a/changelogs/archive/5.0.0/http.yml b/changelogs/archive/5.0.0/http.yml new file mode 100644 index 000000000..e9becfcef --- /dev/null +++ b/changelogs/archive/5.0.0/http.yml @@ -0,0 +1,2 @@ +minor_changes: + - Several modules - Remove unnecessary HTTP codes which get already imported via utils.py. diff --git a/changelogs/archive/5.0.0/lookup_folder.yml b/changelogs/archive/5.0.0/lookup_folder.yml new file mode 100644 index 000000000..d4ee200e4 --- /dev/null +++ b/changelogs/archive/5.0.0/lookup_folder.yml @@ -0,0 +1,4 @@ +breaking_changes: + - Folder lookup module - Return the complete folder information, not only the extensions. + To keep the current behavior in your playbooks, you want to use `{{ my_lookup_result.extensions }}` + instead of `{{ my_lookup_result }}`. diff --git a/changelogs/archive/5.0.0/release_summary.yml b/changelogs/archive/5.0.0/release_summary.yml new file mode 100644 index 000000000..3c2b63a9a --- /dev/null +++ b/changelogs/archive/5.0.0/release_summary.yml @@ -0,0 +1 @@ +release_summary: "(Re)writing history with overhauled modules and updated Checkmk, Ansible, Distribution and Python support." diff --git a/changelogs/archive/5.0.0/roles.yml b/changelogs/archive/5.0.0/roles.yml new file mode 100644 index 000000000..f0c03a69d --- /dev/null +++ b/changelogs/archive/5.0.0/roles.yml @@ -0,0 +1,3 @@ +minor_changes: + - Agent role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. + - Server role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. diff --git a/changelogs/fragments/rule.yml b/changelogs/archive/5.0.0/rule.yml similarity index 93% rename from changelogs/fragments/rule.yml rename to changelogs/archive/5.0.0/rule.yml index 9a606151f..a7b647eab 100644 --- a/changelogs/fragments/rule.yml +++ b/changelogs/archive/5.0.0/rule.yml @@ -1,4 +1,4 @@ -minor_changes: +major_changes: - Rule module - The complete module was rewritten to use the new module API. Additionally, a parameter "rule_id" was introduced to modify existing rules. Refer to the module documentation for further details. diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 1edaa2234..e79f409ce 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -901,3 +901,44 @@ releases: - meta.yml - release_summary.yml release_date: '2024-05-01' + 5.0.0: + changes: + breaking_changes: + - Agent role - Not really a breaking change, but we removed the internal variable + `checkmk_agent_server_ip`. If you set this variable in your inventory, please + make sure to update your configuration accordingly! + - Folder lookup module - Return the complete folder information, not only the + extensions. To keep the current behavior in your playbooks, you want to use + `{{ my_lookup_result.extensions }}` instead of `{{ my_lookup_result }}`. + major_changes: + - Discovery module - The module now fully supports Checkmk 2.3.0. Additionally, + two new parameters were introduced, `update_service_labels` and `monitor_undecided_services`. + Refer to the module documentation for further details. + - Rule module - The complete module was rewritten to use the new module API. + Additionally, a parameter "rule_id" was introduced to modify existing rules. + Refer to the module documentation for further details. + minor_changes: + - Agent role - Add support to open firewall for a list of IPs. + - Agent role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. + - Server role - Replace `ansible.builtin.yum` with the succeeding `ansible.builtin.dnf`. + - Several modules - Remove unnecessary HTTP codes which get already imported + via utils.py. + - Testing - Add Ansible 2.17 to all tests. Be advised, that this Ansible release + drops support for Python 2.7 and 3.6. + - Testing - Add Ubuntu 24.04 to the Molecule tests. + - Testing - All tests now cover Checkmk 2.3.0. + - Testing - Remove Ansible 2.14 from all tests, as it is EOL. + - Testing - Remove Checkmk 2.0.0 from all tests, as it is EOL. + - Testing - The Molecule tests now run on Ubuntu 22.04. + release_summary: (Re)writing history with overhauled modules and updated Checkmk, + Ansible, Distribution and Python support. + fragments: + - agent.yml + - build.yml + - discovery.yml + - http.yml + - lookup_folder.yml + - release_summary.yml + - roles.yml + - rule.yml + release_date: '2024-06-07' diff --git a/changelogs/fragments/lookup_folder.yml b/changelogs/fragments/lookup_folder.yml deleted file mode 100644 index dc1599cd1..000000000 --- a/changelogs/fragments/lookup_folder.yml +++ /dev/null @@ -1,3 +0,0 @@ -breaking_changes: - - Folder lookup module - Return the complete folder information, not only the extensions. - Refer to the module documentation for more details. diff --git a/docs/activation_module.rst b/docs/activation_module.rst index fb0fc5001..9712f58aa 100644 --- a/docs/activation_module.rst +++ b/docs/activation_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -400,35 +400,35 @@ Examples - name: "Start activation on all sites." checkmk.general.activation: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" run_once: 'true' - name: "Start activation on a specific site." checkmk.general.activation: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" sites: - - "my_site" + - "mysite" run_once: 'true' - name: "Start activation including foreign changes." checkmk.general.activation: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" force_foreign_changes: 'true' run_once: 'true' - name: "Activate changes including foreign changes and wait for completion." checkmk.general.activation: server_url: "http://localhost/" - site: "my_site" + site: "mysite" automation_user: "automation" automation_secret: "$SECRET" redirect: 'true' diff --git a/docs/bakery_lookup.rst b/docs/bakery_lookup.rst index ddbb15370..4ef2fc074 100644 --- a/docs/bakery_lookup.rst +++ b/docs/bakery_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -391,8 +391,8 @@ Examples msg: "Bakery status is {{ bakery }}" vars: bakery: "{{ lookup('checkmk.general.bakery', - server_url=http://my_server, - site=my_site, + server_url=http://myserver, + site=mysite, validate_certs=False, automation_user=automation_user, automation_secret=automation_secret @@ -402,10 +402,10 @@ Examples ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false bakery: "{{ lookup('checkmk.general.bakery') }}" diff --git a/docs/bakery_module.rst b/docs/bakery_module.rst index dd1bee224..c2861f9f3 100644 --- a/docs/bakery_module.rst +++ b/docs/bakery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -389,28 +389,28 @@ Examples # Bake all agents without signing, as example in a fresh installation without a signature key. - name: "Bake all agents without signing." checkmk.general.bakery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" state: "baked" # Sign all agents. - name: "Sign all agents." checkmk.general.bakery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" signature_key_id: 1 signature_key_passphrase: "my_key" state: "signed" # Bake and sign all agents. - name: "Bake and sign all agents." checkmk.general.bakery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" signature_key_id: 1 signature_key_passphrase: "my_key" state: "baked_signed" diff --git a/docs/contact_group_module.rst b/docs/contact_group_module.rst index d5be4ec9b..0db6cf9cb 100644 --- a/docs/contact_group_module.rst +++ b/docs/contact_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -460,10 +460,10 @@ Examples # Create a single contact group. - name: "Create a single contact group." checkmk.general.contact_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_contact_group" title: "My Contact Group" customer: "provider" @@ -472,10 +472,10 @@ Examples # Create several contact groups. - name: "Create several contact groups." checkmk.general.contact_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_contact_group_one" @@ -489,10 +489,10 @@ Examples # Create several contact groups. - name: "Create several contact groups." checkmk.general.contact_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_contact_group_one" @@ -504,20 +504,20 @@ Examples # Delete a single contact group. - name: "Create a single contact group." checkmk.general.contact_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_contact_group" state: "absent" # Delete several contact groups. - name: "Delete several contact groups." checkmk.general.contact_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" groups: - name: "my_contact_group_one" - name: "my_contact_group_two" diff --git a/docs/discovery_module.rst b/docs/discovery_module.rst index a45fcfe57..ccc3821ce 100644 --- a/docs/discovery_module.rst +++ b/docs/discovery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -449,6 +449,8 @@ Parameters - :ansible-option-choices-entry:`"refresh"` - :ansible-option-choices-entry:`"tabula\_rasa"` - :ansible-option-choices-entry:`"only\_host\_labels"` + - :ansible-option-choices-entry:`"only\_service\_labels"` + - :ansible-option-choices-entry:`"monitor\_undecided\_services"` .. raw:: html @@ -518,34 +520,34 @@ Examples # Create a single host. - name: "Add newly discovered services on host." checkmk.general.discovery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" host_name: "my_host" state: "new" - name: "Add newly discovered services, update labels and remove vanished services on host." checkmk.general.discovery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" host_name: "my_host" state: "fix_all" - name: "Add newly discovered services on hosts. (Bulk)" checkmk.general.discovery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" hosts: ["my_host_0", "my_host_1"] state: "new" - name: "Add newly discovered services, update labels and remove vanished services on host; 3 at once (Bulk)" checkmk.general.discovery: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" hosts: ["my_host_0", "my_host_1", "my_host_2", "my_host_3", "my_host_4", "my_host_5"] state: "fix_all" bulk_size: 3 @@ -674,6 +676,7 @@ Authors - Robin Gierse (@robin-checkmk) - Michael Sekania (@msekania) +- Max Sickora (@max-checkmk) diff --git a/docs/downtime_module.rst b/docs/downtime_module.rst index 39d0aa40d..4579de2cc 100644 --- a/docs/downtime_module.rst +++ b/docs/downtime_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -667,7 +667,7 @@ Examples - name: "Schedule host downtime." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ my_site }}" + site: "{{ mysite }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host @@ -680,7 +680,7 @@ Examples - name: "Schedule service downtimes for two given services." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ my_site }}" + site: "{{ mysite }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host @@ -695,7 +695,7 @@ Examples - name: "Delete all service downtimes for two given services." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ my_site }}" + site: "{{ mysite }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst index cc4bf9d75..964563bdd 100644 --- a/docs/environment_variables.rst +++ b/docs/environment_variables.rst @@ -2,7 +2,7 @@ :orphan: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.0 .. _list_of_collection_env_vars: diff --git a/docs/folder_lookup.rst b/docs/folder_lookup.rst index b3de84985..1c66bd423 100644 --- a/docs/folder_lookup.rst +++ b/docs/folder_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -443,29 +443,28 @@ Examples .. code-block:: yaml+jinja - - name: Get the attributes of folder /tests + - name: Get the attributes of folders /tests and /snmp ansible.builtin.debug: - msg: "Attributes of folder /network: {{ attributes }}" - vars: - attributes: "{{ - lookup('checkmk.general.folder', - '~tests', - server_url=my_server_url, - site=my_site, - automation_user=my_user, - automation_secret=my_secret, - validate_certs=False - ) - }}" + msg: "Extended attributes of folder /network: {{ attributes.extensions }}" + loop: "{{ + lookup('checkmk.general.folder', + '~tests', '~snmp', + server_url=my_server_url, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, + validate_certs=False + ) + }}" - name: "Use variables outside the module call." ansible.builtin.debug: - msg: "Attributes of folder /network: {{ attributes }}" + msg: "Extended attributes of folder /network: {{ attributes.extensions }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" @@ -518,7 +517,9 @@ Return Value
- A list of dicts of attributes of the folder(s) + A dict of attributes of the folder if you query a single folder + + A list of dicts of attributes of the folders if you query multiple folders .. rst-class:: ansible-option-line diff --git a/docs/folder_module.rst b/docs/folder_module.rst index e4b2a3fc8..f66d3efc7 100644 --- a/docs/folder_module.rst +++ b/docs/folder_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -536,10 +536,10 @@ Examples # Create a single folder. - name: "Create a single folder." checkmk.general.folder: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" path: "/my_folder" name: "My Folder" state: "present" @@ -547,10 +547,10 @@ Examples # Create a folder who's hosts should be hosted on a remote site. - name: "Create a single folder." checkmk.general.folder: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" path: "/my_remote_folder" name: "My Remote Folder" attributes: @@ -560,10 +560,10 @@ Examples # Create a folder with Criticality set to a Test system and Networking Segment WAN (high latency)" - name: "Create a folder with tag_criticality test and tag_networking wan" checkmk.general.folder: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" path: "/my_remote_folder" attributes: tag_criticality: "test" @@ -573,10 +573,10 @@ Examples # Update only specified attributes - name: "Update only specified attributes" checkmk.general.folder: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" path: "/my_folder" update_attributes: tag_networking: "dmz" @@ -585,10 +585,10 @@ Examples # Remove specified attributes - name: "Remove specified attributes" checkmk.general.folder: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" path: "/my_folder" remove_attributes: - tag_networking diff --git a/docs/folders_lookup.rst b/docs/folders_lookup.rst index aff2e7d96..864c41678 100644 --- a/docs/folders_lookup.rst +++ b/docs/folders_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -543,9 +543,9 @@ Examples show_hosts=False, recursive=True, server_url=my_server_url, - site=my_site, - automation_user=my_user, - automation_secret=my_secret, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, validate_certs=False ) }}" @@ -562,9 +562,9 @@ Examples show_hosts=True, recursive=True, server_url=my_server_url, - site=my_site, - automation_user=my_user, - automation_secret=my_secret, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, validate_certs=False ) }}" @@ -576,10 +576,10 @@ Examples ansible.builtin.debug: msg: "Folder tree: {{ item.id }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.folders', diff --git a/docs/host_group_module.rst b/docs/host_group_module.rst index cfa71e0c2..f4718e87a 100644 --- a/docs/host_group_module.rst +++ b/docs/host_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -460,10 +460,10 @@ Examples # Create a single host group. - name: "Create a single host group." checkmk.general.host_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host_group" title: "My Host Group" customer: "provider" @@ -472,10 +472,10 @@ Examples # Create several host groups. - name: "Create several host groups." checkmk.general.host_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_host_group_one" @@ -489,10 +489,10 @@ Examples # Create several host groups. - name: "Create several host groups." checkmk.general.host_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_host_group_one" @@ -504,20 +504,20 @@ Examples # Delete a single host group. - name: "Delete a single host group." checkmk.general.host_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host_group" state: "absent" # Delete several host groups. - name: "Delete several host groups." checkmk.general.host_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" groups: - name: "my_host_group_one" - name: "my_host_group_two" diff --git a/docs/host_lookup.rst b/docs/host_lookup.rst index c3e861a86..ffc6cae7d 100644 --- a/docs/host_lookup.rst +++ b/docs/host_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -497,9 +497,9 @@ Examples 'example.com', effective_attributes=True, server_url=my_server_url, - site=my_site, - automation_user=my_user, - automation_secret=my_secret, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, validate_certs=False ) }}" @@ -508,10 +508,10 @@ Examples ansible.builtin.debug: msg: "Attributes of host example: {{ attributes }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" 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 a0a72c970..f8933a80a 100644 --- a/docs/host_module.rst +++ b/docs/host_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -634,10 +634,10 @@ Examples # Create a host. - name: "Create a host." checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" folder: "/" state: "present" @@ -645,10 +645,10 @@ Examples # Create a host with IP. - name: "Create a host with IP address." checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" attributes: alias: "My Host" @@ -659,10 +659,10 @@ Examples # Create a host which is monitored on a distinct site. - name: "Create a host which is monitored on a distinct site." checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" attributes: site: "my_remote_site" @@ -672,10 +672,10 @@ Examples # Create a cluster host. - name: "Create a cluster host." checkmk.general.cluster: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_cluster_host" folder: "/" nodes: ["cluster_node_1", "cluster_node_2", "cluster_node_3"] @@ -684,10 +684,10 @@ Examples # Create a cluster host with IP. - name: "Create a cluster host with IP address." checkmk.general.cluster: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_cluster_host" nodes: - "cluster_node_1" @@ -702,10 +702,10 @@ Examples # Create a host with update_attributes. - name: "Create a host which is monitored on a distinct site." checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" update_attributes: site: "my_remote_site" @@ -714,10 +714,10 @@ Examples # Update only specified attributes - name: "Update only specified attributes" checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" update_attributes: alias: "foo" @@ -726,10 +726,10 @@ Examples # Remove specified attributes - name: "Remove specified attributes" checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" remove_attributes: - alias @@ -738,10 +738,10 @@ Examples # Add custom tags to a host (note the leading 'tag_') - name: "Remove specified attributes" checkmk.general.host: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_host" update_attributes: - tag_my_tag_1: "Bar" diff --git a/docs/hosts_lookup.rst b/docs/hosts_lookup.rst index 8e83b29a8..42c038cfe 100644 --- a/docs/hosts_lookup.rst +++ b/docs/hosts_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -439,9 +439,9 @@ Examples lookup('checkmk.general.hosts', effective_attributes=True, server_url=my_server_url, - site=my_site, - automation_user=my_user, - automation_secret=my_secret, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, validate_certs=False ) }}" @@ -452,10 +452,10 @@ Examples ansible.builtin.debug: msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.hosts', effective_attributes=True) }}" diff --git a/docs/index.rst b/docs/index.rst index 85e9793ed..b3e477228 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.0 .. _plugins_in_checkmk.general: @@ -9,7 +9,7 @@ Checkmk.General =============== -Collection version 4.4.1 +Collection version 5.0.0 .. contents:: :local: @@ -29,7 +29,7 @@ The official Checkmk Ansible collection - brought to you by the Checkmk company. **Supported ansible-core versions:** -* 2.12.0 or newer +* 2.14.0 or newer .. ansible-links:: diff --git a/docs/password_module.rst b/docs/password_module.rst index dd49ec3bc..970d886f4 100644 --- a/docs/password_module.rst +++ b/docs/password_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -593,10 +593,10 @@ Examples # If passwords are configured, no_log should be set to true. - name: "Create a new password." checkmk.general.password: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "mypassword" title: "My Password" customer: "provider" @@ -611,10 +611,10 @@ Examples no_log: true - name: "Delete a password." checkmk.general.password: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "mypassword" state: "absent" diff --git a/docs/rule_lookup.rst b/docs/rule_lookup.rst index 0dc2c84c5..a957be440 100644 --- a/docs/rule_lookup.rst +++ b/docs/rule_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.0 .. Anchors @@ -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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -442,10 +442,10 @@ Examples ansible.builtin.debug: msg: "Rule: {{ extensions }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" 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 46cbd71f3..d773bab5d 100644 --- a/docs/rule_module.rst +++ b/docs/rule_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -263,8 +263,6 @@ Parameters By default rules are created at the bottom of the "/" folder. - Mutually exclusive with \ :emphasis:`folder`\ . - .. raw:: html @@ -307,11 +305,11 @@ Parameters Folder of the rule. - Required when \ :emphasis:`position`\ is \ :literal:`top`\ or \ :literal:`bottom`\ . + Required when \ :emphasis:`position`\ is \ :literal:`top`\ , \ :literal:`bottom`\ , or (any). Required when \ :emphasis:`state=absent`\ . - Mutually exclusive with \ :emphasis:`rule\_id`\ . + Mutually exclusive with \ :emphasis:`neighbour`\ . .. rst-class:: ansible-option-line @@ -325,24 +323,28 @@ Parameters * - .. raw:: html
-
+
+
.. raw:: latex \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} - .. _ansible_collections.checkmk.general.rule_module__parameter-rule/location/position: + .. _ansible_collections.checkmk.general.rule_module__parameter-rule/location/neighbour: + .. _ansible_collections.checkmk.general.rule_module__parameter-rule/location/rule_id: .. rst-class:: ansible-option-title - **position** + **neighbour** .. raw:: html - + .. ansible-option-type-line:: + :ansible-option-aliases:`aliases: rule_id` + :ansible-option-type:`string` .. raw:: html @@ -357,19 +359,11 @@ Parameters
- Position of the rule in the folder. - - Has no effect when \ :emphasis:`state=absent`\ . - - - .. rst-class:: ansible-option-line + Put the rule \ :literal:`before`\ or \ :literal:`after`\ this rule\_id. - :ansible-option-choices:`Choices:` + Required when \ :emphasis:`position`\ is \ :literal:`before`\ or \ :literal:`after`\ . - - :ansible-option-choices-entry:`"top"` - - :ansible-option-choices-entry-default:`"bottom"` :ansible-option-choices-default-mark:`← (default)` - - :ansible-option-choices-entry:`"before"` - - :ansible-option-choices-entry:`"after"` + Mutually exclusive with \ :emphasis:`folder`\ . .. raw:: html @@ -379,21 +373,21 @@ Parameters * - .. raw:: html
-
+
.. raw:: latex \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} - .. _ansible_collections.checkmk.general.rule_module__parameter-rule/location/rule_id: + .. _ansible_collections.checkmk.general.rule_module__parameter-rule/location/position: .. rst-class:: ansible-option-title - **rule_id** + **position** .. raw:: html - + .. ansible-option-type-line:: @@ -411,11 +405,22 @@ Parameters
- Put the rule \ :literal:`before`\ or \ :literal:`after`\ this rule\_id. + Position of the rule in the folder. - Required when \ :emphasis:`position`\ is \ :literal:`before`\ or \ :literal:`after`\ . + Has no effect when \ :emphasis:`state=absent`\ . - Mutually exclusive with \ :emphasis:`folder`\ . + For new rule \ :literal:`any`\ wil be equivalent to \ :literal:`bottom`\ + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"top"` + - :ansible-option-choices-entry:`"bottom"` + - :ansible-option-choices-entry-default:`"any"` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`"before"` + - :ansible-option-choices-entry:`"after"` .. raw:: html @@ -500,9 +505,11 @@ Parameters
- If given, it will be \ :literal:`the only condition`\ to identify the rule to work on. + If provided, update/delete an existing rule. + + If omitted, we try to find an equal rule based on \ :literal:`properties`\ , \ :literal:`conditions`\ , \ :literal:`folder`\ and \ :literal:`value\_raw`\ . - When there's no rule found with this id, the task will fail. + Please mind the additional notes below. .. raw:: html @@ -546,6 +553,8 @@ Parameters Rule values as exported from the web interface. + Required when \ :emphasis:`state`\ is \ :literal:`present`\ . + .. raw:: html @@ -748,7 +757,8 @@ Notes ----- .. note:: - - To achieve idempotency, this module is comparing the specified rule with the already existing rules based on conditions, folder, value\_raw and enabled/disabled. + - If rule\_id is omitted, due to the internal processing of the \ :literal:`value\_raw`\ , finding the matching rule is not reliable, when \ :literal:`rule\_id`\ is omitted. This sometimes leads to the module not being idempotent or to rules being created over and over again. + - If rule\_id is provided, for the same reason, it might happen, that tasks changing a rule again and again, even if it already meets the expectations. .. Seealso @@ -765,10 +775,10 @@ Examples # at the top of the main folder. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." checkmk.general.rule: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { @@ -783,10 +793,10 @@ Examples "service_labels": [] } properties: { - "comment": "Warning at 80%\nCritical at 90%\n", + "comment": "Ansible managed", "description": "Allow higher memory usage", "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rule.py" } value_raw: "{'levels': (80.0, 90.0)}" location: @@ -797,20 +807,47 @@ Examples - name: Show the ID of the new rule ansible.builtin.debug: - msg: "RULE ID : {{ response.id }}" + msg: "RULE ID : {{ response.content.id }}" - # Create another rule in checkgroup_parameters:memory_percentage_used - # and put it after the rule created above. + # Create another rule with the new label conditions (> 2.3.0) + # in checkgroup_parameters:memory_percentage_used and put it after the rule created above. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." checkmk.general.rule: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { - "host_labels": [], + "host_label_groups": [ + { + operator: "and", + label_group: [ + { + operator: "and", + label: "cmk/site:beta" + }, + { + operator: "or", + label: "cmk/os_family:linux" + } + ], + }, + { + operator: "or", + label_group: [ + { + operator: "and", + label: "cmk/site:alpha" + }, + { + operator: "or", + label: "cmk/os_family:windows" + } + ], + }, + ], "host_name": { "match_on": [ "test2.tld" @@ -821,53 +858,36 @@ Examples "service_labels": [] } properties: { - "comment": "Warning at 85%\nCritical at 99%\n", + "comment": "Ansible managed", "description": "Allow even higher memory usage", "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rule.py" } value_raw: "{'levels': (85.0, 99.0)}" location: position: "after" - rule_id: "{{ response.id }}" + neighbour: "{{ response.content.id }}" state: "present" # Delete the first rule. - name: "Delete a rule." checkmk.general.rule: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: - conditions: { - "host_labels": [], - "host_name": { - "match_on": [ - "test1.tld" - ], - "operator": "one_of" - }, - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "Warning at 80%\nCritical at 90%\n", - "description": "Allow higher memory usage", - "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" - } - value_raw: "{'levels': (80.0, 90.0)}" + rule_id: "{{ response.content.id }}" state: "absent" # Create a rule rule matching a host label - name: "Create a rule matching a label." checkmk.general.rule: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { @@ -878,15 +898,12 @@ Examples "value": "yes" } ], - "host_name": {}, - "host_tags": [], - "service_labels": [] } properties: { - "comment": "Warning at 80%\nCritical at 90%\n", + "comment": "Ansible managed", "description": "Allow higher memory usage", "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rule.py" } value_raw: "{'levels': (80.0, 90.0)}" location: @@ -894,6 +911,31 @@ Examples position: "top" state: "present" + # Delete all rules in a ruleset that match a certain comment. + - name: "Delete all rules in a ruleset that match a certain comment." + checkmk.general.rule: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + ruleset: "checkgroup_parameters:memory_percentage_used" + rule: + rule_id: "{{ item.id }}" + state: "absent" + loop: "{{ + lookup('checkmk.general.rules', + ruleset='checkgroup_parameters:memory_percentage_used', + comment_regex='Ansible managed', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + loop_control: + label: "{{ item.id }}" + @@ -920,9 +962,390 @@ Common return values are documented :ref:`here `, the foll * - .. raw:: html
-
+
+ + .. _ansible_collections.checkmk.general.rule_module__return-content: + + .. rst-class:: ansible-option-title + + **content** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The complete created/changed rule + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions: + + .. rst-class:: ansible-option-title + + **extensions** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The attributes of the rule + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/conditions: + + .. rst-class:: ansible-option-title + + **conditions** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The contitions of the rule. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/folder: + + .. rst-class:: ansible-option-title + + **folder** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The folder of the rule. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/folder_index: + + .. rst-class:: ansible-option-title + + **folder_index** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The index of the rule inside the folder. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/properties: + + .. rst-class:: ansible-option-title + + **properties** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The properties of the rule. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/ruleset: + + .. rst-class:: ansible-option-title + + **ruleset** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The ruleset of the rule. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/extensions/value_raw: + + .. rst-class:: ansible-option-title + + **value_raw** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The actual value of the rule + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + + .. raw:: html + +
+ - .. _ansible_collections.checkmk.general.rule_module__return-id: + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__return-content/id: .. rst-class:: ansible-option-title @@ -930,7 +1353,7 @@ Common return values are documented :ref:`here `, the foll .. raw:: html - + .. ansible-option-type-line:: @@ -940,9 +1363,13 @@ Common return values are documented :ref:`here `, the foll
+ .. raw:: latex + + \end{minipage} + - .. raw:: html -
+
The ID of the rule. @@ -962,6 +1389,97 @@ Common return values are documented :ref:`here `, the foll
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.rule_module__return-etag: + + .. rst-class:: ansible-option-title + + **etag** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The etag of the rule. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` when the rule is created or when it already exists + + .. rst-class:: ansible-option-line + .. rst-class:: ansible-option-sample + + :ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`"\\"ad55730d5488e55e07c58a3da9759fba8cd0b009\\""` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.rule_module__return-http_code: + + .. rst-class:: ansible-option-title + + **http_code** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The HTTP code the Checkmk API returns. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` always + + .. rst-class:: ansible-option-line + .. rst-class:: ansible-option-sample + + :ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`200` + + + .. raw:: html + +
+ + * - .. raw:: html
@@ -1016,8 +1534,10 @@ Common return values are documented :ref:`here `, the foll Authors ~~~~~~~ +- Lars Getwan (@lgetwan) - diademiemi (@diademiemi) - Geoffroy Stévenne (@geof77) +- Michael Sekania (@msekania) diff --git a/docs/rules_lookup.rst b/docs/rules_lookup.rst index c02bd3a0c..b51e7300b 100644 --- a/docs/rules_lookup.rst +++ b/docs/rules_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.0 .. Anchors @@ -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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -220,7 +220,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and
- A regex to filter for certain comment stings. + A regex to filter for certain comment strings. .. rst-class:: ansible-option-line @@ -264,6 +264,47 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and A regex to filter for certain descriptions. + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`""` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.rules_lookup__parameter-folder_regex: + + .. rst-class:: ansible-option-title + + **folder_regex** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + A regex to filter for certain folders. + + .. rst-class:: ansible-option-line :ansible-option-default-bold:`Default:` :ansible-option-default:`""` @@ -521,6 +562,23 @@ Examples loop_control: label: "{{ item.id }}" + - name: Get all rules of the ruleset host_groups in folder /test + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + loop: "{{ + lookup('checkmk.general.rules', + ruleset='host_groups', + regex_folder='^/test$', + 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 }}" @@ -543,10 +601,10 @@ Examples ansible.builtin.debug: msg: "Rule: {{ item.extensions }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups') }}" diff --git a/docs/ruleset_lookup.rst b/docs/ruleset_lookup.rst index f38a6c287..ef670b0cc 100644 --- a/docs/ruleset_lookup.rst +++ b/docs/ruleset_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.0 .. Anchors @@ -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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -442,10 +442,10 @@ Examples ansible.builtin.debug: msg: "Ruleset: {{ extensions }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" 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 75fceb231..1629b089f 100644 --- a/docs/rulesets_lookup.rst +++ b/docs/rulesets_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -595,10 +595,10 @@ Examples ansible.builtin.debug: msg: "Ruleset {{ item.extension.name }} is deprecated." vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false loop: "{{ lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" diff --git a/docs/service_group_module.rst b/docs/service_group_module.rst index beeff8dac..6ccabee34 100644 --- a/docs/service_group_module.rst +++ b/docs/service_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -460,10 +460,10 @@ Examples # Create a single service group. - name: "Create a single service group." checkmk.general.service_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_service_group" title: "My Service Group" customer: "provider" @@ -472,10 +472,10 @@ Examples # Create several service groups. - name: "Create several service groups." checkmk.general.service_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_service_group_one" @@ -489,10 +489,10 @@ Examples # Create several service groups. - name: "Create several service groups." checkmk.general.service_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" customer: "provider" groups: - name: "my_service_group_one" @@ -504,20 +504,20 @@ Examples # Delete a single service group. - name: "Create a single service group." checkmk.general.service_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "my_service_group" state: "absent" # Delete several service groups. - name: "Delete several service groups." checkmk.general.service_group: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" groups: - name: "my_service_group_one" - name: "my_service_group_two" diff --git a/docs/tag_group_module.rst b/docs/tag_group_module.rst index 7787df47e..1c684d86b 100644 --- a/docs/tag_group_module.rst +++ b/docs/tag_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -645,10 +645,10 @@ Examples # Create a tag group - name: "Create tag group" checkmk.general.tag_group: - server_url: "https://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "https://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: datacenter title: Datacenter topic: Tags @@ -667,10 +667,10 @@ Examples # Delete a tag group - name: "Delete tag group." checkmk.general.tag_group: - server_url: "https://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "https://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: datacenter state: "absent" diff --git a/docs/timeperiod_module.rst b/docs/timeperiod_module.rst index 91d42024a..2ca50588e 100644 --- a/docs/timeperiod_module.rst +++ b/docs/timeperiod_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -490,10 +490,10 @@ Examples # Creating and Updating is the same. - name: "Create a new time period. (Attributes in one line)" checkmk.general.timeperiod: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "worktime" alias: "Worktime" active_time_ranges: '[{"day": "all", "time_ranges": [{"start": "09:00:00", "end": "17:00:00"}]}]' @@ -503,10 +503,10 @@ Examples - name: "Create a new time period. (Attributes in multiple lines)" checkmk.general.timeperiod: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "worktime" alias: "Worktime" active_time_ranges: [ @@ -538,10 +538,10 @@ Examples - name: "Delete a time period." checkmk.general.timeperiod: - server_url: "http://my_server/" - site: "my_site" - automation_user: "my_user" - automation_secret: "my_secret" + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" name: "worktime" state: "absent" diff --git a/docs/user_module.rst b/docs/user_module.rst index 5a4116307..2f3ca9fe2 100644 --- a/docs/user_module.rst +++ b/docs/user_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This module is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -1208,10 +1208,10 @@ Examples # Create a user. - name: "Create a user." checkmk.general.user: - server_url: "http://my_server/" + server_url: "http://myserver/" site: "local" - automation_user: "my_user" - automation_secret: "my_secret" + automation_user: "myuser" + automation_secret: "mysecret" name: "krichards" fullname: "Keith Richards" email: "keith.richards@rollingstones.com" @@ -1225,10 +1225,10 @@ Examples # Create an automation user. - name: "Create an automation user." checkmk.general.user: - server_url: "http://my_server/" + server_url: "http://myserver/" site: "local" - automation_user: "my_user" - automation_secret: "my_secret" + automation_user: "myuser" + automation_secret: "mysecret" name: "registration" fullname: "Registration User" auth_type: "automation" @@ -1240,10 +1240,10 @@ Examples # Create a user with the Checkmk Managed Edition (CME), using the `customer` parameter. - name: "Create a user." checkmk.general.user: - server_url: "http://my_server/" + server_url: "http://myserver/" site: "local" - automation_user: "my_user" - automation_secret: "my_secret" + automation_user: "myuser" + automation_secret: "mysecret" name: "krichards" fullname: "Keith Richards" email: "keith.richards@rollingstones.com" @@ -1258,10 +1258,10 @@ Examples # Create a detailed user. - name: "Create a more complex user." checkmk.general.user: - server_url: "http://my_server/" + server_url: "http://myserver/" site: "local" - automation_user: "my_user" - automation_secret: "my_secret" + automation_user: "myuser" + automation_secret: "mysecret" name: "horst" fullname: "Horst Schlämmer" customer: "provider" @@ -1281,7 +1281,7 @@ Examples roles: - "user" authorized_sites: - - "{{ my_site }}" + - "{{ mysite }}" interface_theme: "dark" sidebar_position: "right" navigation_bar_icons: "show" diff --git a/docs/version_lookup.rst b/docs/version_lookup.rst index a09fed791..a4f3cdb49 100644 --- a/docs/version_lookup.rst +++ b/docs/version_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.10.0 + :antsibull-docs: 2.11.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.4.1). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -392,20 +392,20 @@ Examples vars: version: "{{ lookup('checkmk.general.version', server_url=my_url, - site=my_site, + site=mysite, validate_certs=False, - automation_user=my_user, - automation_secret=my_secret + automation_user=myuser, + automation_secret=mysecret )}}" - name: "Use variables outside the module call." ansible.builtin.debug: msg: "Server version is {{ version }}" vars: - ansible_lookup_checkmk_server_url: "http://my_server/" - ansible_lookup_checkmk_site: "my_site" - ansible_lookup_checkmk_automation_user: "my_user" - ansible_lookup_checkmk_automation_secret: "my_secret" + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" ansible_lookup_checkmk_validate_certs: false attributes: "{{ lookup('checkmk.general.version') }}" diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 0cf53d4e6..e4e058bb8 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -88,24 +88,23 @@ """ EXAMPLES = """ -- name: Get the attributes of folder /tests +- name: Get the attributes of folders /tests and /snmp ansible.builtin.debug: - msg: "Attributes of folder /network: {{ attributes }}" - vars: - attributes: "{{ - lookup('checkmk.general.folder', - '~tests', - server_url=my_server_url, - site=mysite, - automation_user=myuser, - automation_secret=mysecret, - validate_certs=False - ) - }}" + msg: "Extended attributes of folder /network: {{ attributes.extensions }}" + loop: "{{ + lookup('checkmk.general.folder', + '~tests', '~snmp', + server_url=my_server_url, + site=mysite, + automation_user=myuser, + automation_secret=mysecret, + validate_certs=False + ) + }}" - name: "Use variables outside the module call." ansible.builtin.debug: - msg: "Attributes of folder /network: {{ attributes }}" + msg: "Extended attributes of folder /network: {{ attributes.extensions }}" vars: ansible_lookup_checkmk_server_url: "http://myserver/" ansible_lookup_checkmk_site: "mysite" @@ -118,7 +117,8 @@ RETURN = """ _list: description: - - A list of dicts of attributes of the folder(s) + - A dict of attributes of the folder if you query a single folder + - A list of dicts of attributes of the folders if you query multiple folders type: list elements: str """ diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index a16f3c69d..bdb01927b 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -44,7 +44,7 @@ def __init__(self, module): # may be "present", "abesent" or an individual one self.state = "" - def _fetch(self, code_mapping, endpoint="", data=None, method="GET"): + def _fetch(self, code_mapping="", endpoint="", data=None, method="GET"): http_mapping = GENERIC_HTTP_CODES.copy() http_mapping.update(code_mapping) diff --git a/plugins/module_utils/utils.py b/plugins/module_utils/utils.py index bbdf05a88..5412e3df8 100644 --- a/plugins/module_utils/utils.py +++ b/plugins/module_utils/utils.py @@ -20,12 +20,20 @@ def result_as_dict(result): GENERIC_HTTP_CODES = { - 204: (True, False, "Successfully executed"), + 200: (True, False, "OK: The operation was done successfully"), + 204: (True, False, "Operation done successfully. No further output."), 400: (False, True, "Bad request: Parameter or validation failure"), + 401: (False, True, "The user is not authorized to do this request"), 403: (False, True, "Forbidden: Configuration via Setup is disabled"), - 404: (False, True, "Not found"), - 406: (False, True, "Required headers are not satisfied"), - 412: (False, True, "If-Match does not match ETag"), - 415: (False, True, "Wrong content-type in header"), - 428: (False, True, "If-Match header is missing"), + 404: (False, True, "Not Found: The requested object has not been found"), + 405: ( + False, + True, + "This request is only allowed with other HTTP methods", + ), + 406: (False, True, "The requests accept headers can not be satisfied"), + 412: (False, True, "If-Match header doesn't match the object's ETag"), + 415: (False, True, "The submitted content-type is not supported"), + 428: (False, True, "The required If-Match header is missing"), + 500: (False, True, "General Server Error"), } diff --git a/plugins/modules/bakery.py b/plugins/modules/bakery.py index 964d73bd6..32eaff7d2 100644 --- a/plugins/modules/bakery.py +++ b/plugins/modules/bakery.py @@ -95,29 +95,6 @@ result_as_dict, ) -HTTP_CODES = { - # http_code: (changed, failed, "Message") - 200: (True, False, "The operation was done successfully."), - 204: ( - True, - False, - "No Content: Operation done successfully. No further output.", - ), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via WATO is disabled."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), -} - class BakeryAPI(CheckmkAPI): def post(self): @@ -137,7 +114,6 @@ def post(self): action = "bake_and_sign" return self._fetch( - code_mapping=HTTP_CODES, endpoint="/domain-types/agent/actions/%s/invoke" % action, data=data, method="POST", diff --git a/plugins/modules/discovery.py b/plugins/modules/discovery.py index ee4bc3adf..92603365d 100644 --- a/plugins/modules/discovery.py +++ b/plugins/modules/discovery.py @@ -40,7 +40,7 @@ description: The action to perform during discovery. type: str default: new - choices: [new, remove, fix_all, refresh, tabula_rasa, only_host_labels, update_service_labels, monitor_undecided_services] + choices: [new, remove, fix_all, refresh, tabula_rasa, only_host_labels, only_service_labels, monitor_undecided_services] do_full_scan: description: The option whether to perform a full scan or not. (Bulk mode only). type: bool @@ -131,13 +131,8 @@ False, "The service discovery background job has been initialized. Redirecting to the 'Wait for service discovery completion' endpoint.", ), - 400: (False, True, "Bad Request."), - 403: (False, True, "Forbidden: Configuration via WATO is disabled."), 404: (False, True, "Not Found: Host could not be found."), - 406: (False, True, "Not Acceptable."), 409: (False, False, "Conflict: A discovery background job is already running"), - 415: (False, True, "Unsupported Media Type."), - 500: (False, True, "General Server Error."), } HTTP_CODES_SC = { @@ -148,30 +143,19 @@ False, "The service discovery is still running. Redirecting to the 'Wait for completion' endpoint.", ), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), 404: (False, False, "Not Found: There is no running service discovery"), - 406: (False, True, "Not Acceptable."), - 500: (False, True, "General Server Error."), } HTTP_CODES_BULK = { # http_code: (changed, failed, "Message") 200: (True, False, "Discovery successful."), - 400: (False, True, "Bad Request."), - 403: (False, True, "Forbidden: Configuration via WATO is disabled."), - 406: (False, True, "Not Acceptable."), 409: (False, False, "Conflict: A bulk discovery job is already active"), - 415: (False, True, "Unsupported Media Type."), - 500: (False, True, "General Server Error."), } HTTP_CODES_BULK_SC = { # http_code: (changed, failed, "Message") 200: (True, False, "The service discovery has been completed."), - 403: (False, True, "Forbidden: Configuration via WATO is disabled."), 404: (False, False, "Not Found: There is no running bulk_discovery job"), - 406: (False, True, "Not Acceptable."), - 500: (False, True, "General Server Error."), } @@ -255,7 +239,7 @@ def post(self): options["monitor_undecided_services"] = True if self.params.get("state") in ["remove", "fix_all"]: options["remove_vanished_services"] = True - if self.params.get("state") in ["update_service_labels"]: + if self.params.get("state") in ["only_service_labels"]: options["update_service_labels"] = True if self.params.get("state") in ["new", "fix_all", "only_host_labels"]: options["update_host_labels"] = True @@ -336,7 +320,7 @@ def run_module(): "refresh", "tabula_rasa", "only_host_labels", - "update_service_labels", + "only_service_labels", "monitor_undecided_services", ], ), @@ -400,7 +384,7 @@ def run_module(): module.params["state"] = "refresh" if module.params.get("state") in [ - "update_service_labels", + "only_service_labels", "monitor_undecided_services", ]: if ver < CheckmkVersion("2.3.0"): @@ -426,7 +410,7 @@ def run_module(): module.fail_json(**result_as_dict(result)) if module.params.get( "state" - ) == "update_service_labels" and ver < CheckmkVersion("2.3.0p3"): + ) == "only_service_labels" and ver < CheckmkVersion("2.3.0p3"): result = RESULT( http_code=0, msg="State can only be used in bulk mode", diff --git a/plugins/modules/password.py b/plugins/modules/password.py index 77f4e824b..16774ab96 100644 --- a/plugins/modules/password.py +++ b/plugins/modules/password.py @@ -132,90 +132,12 @@ # We count 404 not as failed, because we want to know if the password exists or not. HTTP_CODES_GET = { # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), 404: (False, False, "Not Found: The requested object has not been found."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), } HTTP_CODES_DELETE = { # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), 404: (False, False, "Not Found: The requested object has not been found."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_CREATE = { - # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_UPDATE = { - # http_code: (changed, failed, "Message") - 200: ( - True, - False, - "No Content: Operation was done successfully. No further output", - ), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), - 404: (False, True, "Not Found: The requested object has not been found."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 412: ( - False, - True, - "Precondition Failed: The value of the If-Match header doesn't match the object's ETag.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 428: ( - False, - True, - "Precondition Required: The required If-Match header is missing.", - ), - 500: (False, True, "General Server Error."), } @@ -236,7 +158,6 @@ def post(self): data = {key: val for key, val in data.items() if val} return self._fetch( - code_mapping=HTTP_CODES_CREATE, endpoint="/domain-types/password/collections/all", data=data, method="POST", @@ -259,7 +180,6 @@ def put(self): data = {key: val for key, val in data.items() if val} return self._fetch( - code_mapping=HTTP_CODES_UPDATE, endpoint="/objects/password/%s" % self.params.get("name"), data=data, method="PUT", diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 3c0b56958..3b37852d1 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -101,7 +101,7 @@ - Lars Getwan (@lgetwan) - diademiemi (@diademiemi) - Geoffroy Stévenne (@geof77) - - Michael Sekana (@msekania) + - Michael Sekania (@msekania) """ EXAMPLES = r""" diff --git a/plugins/modules/tag_group.py b/plugins/modules/tag_group.py index 90f61a36a..e3e21605d 100644 --- a/plugins/modules/tag_group.py +++ b/plugins/modules/tag_group.py @@ -138,37 +138,7 @@ # We count 404 not as failed, because we want to know if the taggroup exists or not. HTTP_CODES_GET = { # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), 404: (False, False, "Not Found: The requested object has not been found."), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_DELETE = { - # http_code: (changed, failed, "Message") - 405: ( - False, - True, - "Method Not Allowed: This request is only allowed with other HTTP methods", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_CREATE = { - # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_UPDATE = { - # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 401: (False, True, "Unauthorized: The user is not authorized to do this request"), - 405: ( - False, - True, - "Method Not Allowed: This request is only allowed with other HTTP methods", - ), - 500: (False, True, "General Server Error."), } @@ -211,7 +181,6 @@ def post(self): data["ident"] = self.params.get("name") return self._fetch( - code_mapping=HTTP_CODES_CREATE, endpoint="/domain-types/host_tag_group/collections/all", data=data, method="POST", @@ -223,7 +192,6 @@ def put(self): data = normalize_data(self.params) return self._fetch( - code_mapping=HTTP_CODES_UPDATE, endpoint="/objects/host_tag_group/%s" % self.params.get("name"), data=data, method="PUT", @@ -235,7 +203,6 @@ def delete(self): data = {} return self._fetch( - code_mapping=HTTP_CODES_DELETE, endpoint="/objects/host_tag_group/%s?repair=%s" % (self.params.get("name"), self.params.get("repair")), # data=data, diff --git a/plugins/modules/timeperiod.py b/plugins/modules/timeperiod.py index 11db106dc..19d3da4ec 100644 --- a/plugins/modules/timeperiod.py +++ b/plugins/modules/timeperiod.py @@ -148,110 +148,7 @@ # We count 404 not as failed, because we want to know if the time period exists or not. HTTP_CODES_GET = { # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), 404: (False, False, "Not Found: The requested object has not been found."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_DELETE = { - # http_code: (changed, failed, "Message") - 204: (True, False, "No Content: Operation done successfully. No further output."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), - 404: (False, True, "Not Found: The requested object has not been found."), - 405: ( - False, - True, - "Method Not Allowed: This request is only allowed with other HTTP methods", - ), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 412: ( - False, - True, - "Precondition Failed: The value of the If-Match header doesn't match the object's ETag.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 428: ( - False, - True, - "Precondition Required: The required If-Match header is missing", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_CREATE = { - # http_code: (changed, failed, "Message") - 200: (True, False, "OK: The operation was done successfully."), - 400: (False, True, "Bad Request: Parameter or validation failure."), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 500: (False, True, "General Server Error."), -} - -HTTP_CODES_UPDATE = { - # http_code: (changed, failed, "Message") - 200: ( - True, - False, - "No Content: Operation was done successfully. No further output", - ), - 403: (False, True, "Forbidden: Configuration via Setup is disabled."), - 404: (False, True, "Not Found: The requested object has not been found."), - 405: ( - False, - True, - "Method Not Allowed: This request is only allowed with other HTTP methods", - ), - 406: ( - False, - True, - "Not Acceptable: The requests accept headers can not be satisfied.", - ), - 412: ( - False, - True, - "Precondition Failed: The value of the If-Match header doesn't match the object's ETag.", - ), - 415: ( - False, - True, - "Unsupported Media Type: The submitted content-type is not supported.", - ), - 428: ( - False, - True, - "Precondition Required: The required If-Match header is missing", - ), - 500: (False, True, "General Server Error."), } updatevalues = ("alias", "active_time_ranges", "exceptions", "exclude") @@ -272,7 +169,6 @@ def post(self): data["exclude"] = self.params.get("exclude") return self._fetch( - code_mapping=HTTP_CODES_CREATE, endpoint="/domain-types/time_period/collections/all", data=data, method="POST", @@ -299,7 +195,6 @@ def put(self, existingalias): data["exclude"] = self.params.get("exclude") return self._fetch( - code_mapping=HTTP_CODES_UPDATE, endpoint="/objects/time_period/%s" % self.params.get("name"), data=data, method="PUT", @@ -311,7 +206,6 @@ def delete(self): data = {} return self._fetch( - code_mapping=HTTP_CODES_DELETE, endpoint="/objects/time_period/%s" % self.params.get("name"), data=data, method="DELETE", diff --git a/plugins/modules/user.py b/plugins/modules/user.py index baffe3c16..d9d3fe9c7 100644 --- a/plugins/modules/user.py +++ b/plugins/modules/user.py @@ -236,9 +236,6 @@ from ansible_collections.checkmk.general.plugins.module_utils.utils import ( result_as_dict, ) -from ansible_collections.checkmk.general.plugins.module_utils.version import ( - CheckmkVersion, -) USER = ( "username", @@ -409,19 +406,6 @@ def needs_editing(self): return True return False - def shortpassword(self, data): - ver = self.getversion() - if ver >= CheckmkVersion("2.3.0") and "auth_option" in data: - if ( - "password" in data["auth_option"] - and len(data["auth_option"]["password"]) < 12 - ) or ( - "secret" in data["auth_option"] - and len(data["auth_option"]["secret"]) < 10 - ): - return True - return False - def get(self): result = self._fetch( code_mapping=UserHTTPCodes.get, @@ -454,22 +438,12 @@ def edit(self, etag): data = self._build_user_data() self.headers["if-Match"] = etag - if self.shortpassword(data): - result = RESULT( - http_code=0, - msg="Password too short. For 2.3 and higher, please provide at least 12 characters (automation min. 10).", - content="", - etag="", - failed=True, - changed=False, - ) - else: - result = self._fetch( - code_mapping=UserHTTPCodes.edit, - endpoint=self._build_default_endpoint(), - data=data, - method="PUT", - ) + result = self._fetch( + code_mapping=UserHTTPCodes.edit, + endpoint=self._build_default_endpoint(), + data=data, + method="PUT", + ) return result diff --git a/requirements.txt b/requirements.txt index 618ae37ff..b838767ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ jinja2 molecule >= 5.0.1 molecule-plugins[docker] yamllint -pywinrm \ No newline at end of file +pywinrm +netaddr \ No newline at end of file diff --git a/roles/agent/README.md b/roles/agent/README.md index 77d39915d..279641e59 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -11,9 +11,12 @@ It can be installed as easy as running: ansible-galaxy collection install checkmk.general +Additionally, this role requires the Python module `netaddr` on the controller. +Please make sure it is installed on your system and available for Ansible. + ## Role Variables - checkmk_agent_version: "2.3.0p4" + checkmk_agent_version: "2.3.0p5" The Checkmk version of the site your agents will talk to. @@ -134,6 +137,12 @@ Automatically configure the firewall (*currently only on RedHat and Debian deriv When checkmk_agent_configure_firewall is set to `true` then configure the firewall zone on RedHat derivatives. Defaults to 'public'. + checkmk_agent_server_ips: [] + +A list of IP addresses, that will be whitelisted in the firewall for agent access on `checkmk_agent_port`. +The `checkmk_agent_server` will automatically be added, but only if it is an IP address. +This parameter also does **not** take care of any agent-side whitelisting! + checkmk_agent_force_install: 'false' Force the installation of the agent package, no matter the constraints. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index d1a2132ad..950b35e94 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_version: "2.3.0p4" +checkmk_agent_version: "2.3.0p5" checkmk_agent_edition: cre checkmk_agent_server_protocol: http checkmk_agent_server: localhost @@ -23,6 +23,7 @@ checkmk_agent_update: 'false' checkmk_agent_tls: 'false' checkmk_agent_configure_firewall: 'true' checkmk_agent_configure_firewall_zone: 'public' +checkmk_agent_server_ips: [] checkmk_agent_force_install: 'false' checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: localhost diff --git a/roles/agent/molecule/2.1.0/converge.yml b/roles/agent/molecule/2.1.0/converge.yml index 355915cd1..54ff31445 100644 --- a/roles/agent/molecule/2.1.0/converge.yml +++ b/roles/agent/molecule/2.1.0/converge.yml @@ -9,6 +9,7 @@ update_cache: true cache_valid_time: 600 when: ansible_os_family == 'Debian' + - name: Install prerequisites. ansible.builtin.apt: name: "{{ item }}" @@ -16,7 +17,17 @@ loop: - apt-utils - man + - ufw when: ansible_os_family == 'Debian' + + - name: Install prerequisites. + ansible.builtin.dnf: + name: "{{ item }}" + state: present + loop: + - firewalld + when: ansible_os_family == 'RedHat' + - name: Create '/usr/share/man/man8/' on Ubuntu. ansible.builtin.file: path: /usr/share/man/man8/ 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 339d30244..b7436414d 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -28,8 +28,13 @@ checkmk_agent_add_host: 'true' checkmk_agent_discover: 'true' checkmk_agent_discover_max_parallel_tasks: 2 checkmk_agent_update: 'false' -checkmk_agent_tls: 'false' -checkmk_agent_configure_firewall: 'false' +checkmk_agent_tls: 'true' +checkmk_agent_configure_firewall: 'true' +checkmk_agent_configure_firewall_zone: 'public' +checkmk_agent_server_ips: + - 10.10.10.10 + - 172.16.16.16 + - 192.168.1.1 checkmk_agent_force_install: 'false' checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" diff --git a/roles/agent/molecule/2.1.0/molecule.yml b/roles/agent/molecule/2.1.0/molecule.yml index 26b1538bb..b093f6725 100644 --- a/roles/agent/molecule/2.1.0/molecule.yml +++ b/roles/agent/molecule/2.1.0/molecule.yml @@ -5,16 +5,17 @@ dependency: driver: name: docker platforms: - - name: ubuntu2004 - image: geerlingguy/docker-ubuntu2004-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - cgroupns_mode: host - tmpfs: - - /run - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - privileged: true - pre_build_image: true + ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. + # - name: ubuntu2004 + # image: geerlingguy/docker-ubuntu2004-ansible + # command: ${MOLECULE_DOCKER_COMMAND:-""} + # cgroupns_mode: host + # tmpfs: + # - /run + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:rw + # privileged: true + # pre_build_image: true - name: ubuntu2204 image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} @@ -45,16 +46,6 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - cgroupns_mode: host - tmpfs: - - /run - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - privileged: true - pre_build_image: true - name: rockylinux9 image: geerlingguy/docker-rockylinux9-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/molecule/2.2.0/converge.yml b/roles/agent/molecule/2.2.0/converge.yml index 6fa62fce9..54ff31445 100644 --- a/roles/agent/molecule/2.2.0/converge.yml +++ b/roles/agent/molecule/2.2.0/converge.yml @@ -17,8 +17,17 @@ loop: - apt-utils - man + - ufw when: ansible_os_family == 'Debian' + - name: Install prerequisites. + ansible.builtin.dnf: + name: "{{ item }}" + state: present + loop: + - firewalld + when: ansible_os_family == 'RedHat' + - name: Create '/usr/share/man/man8/' on Ubuntu. ansible.builtin.file: path: /usr/share/man/man8/ 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 fd0876c52..d6c2cb9b2 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -28,8 +28,13 @@ checkmk_agent_add_host: 'true' checkmk_agent_discover: 'true' checkmk_agent_discover_max_parallel_tasks: 2 checkmk_agent_update: 'false' -checkmk_agent_tls: 'false' -checkmk_agent_configure_firewall: 'false' +checkmk_agent_tls: 'true' +checkmk_agent_configure_firewall: 'true' +checkmk_agent_configure_firewall_zone: 'public' +checkmk_agent_server_ips: + - 10.10.10.10 + - 172.16.16.16 + - 192.168.1.1 checkmk_agent_force_install: 'false' checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" diff --git a/roles/agent/molecule/2.2.0/molecule.yml b/roles/agent/molecule/2.2.0/molecule.yml index 26b1538bb..c95ee9721 100644 --- a/roles/agent/molecule/2.2.0/molecule.yml +++ b/roles/agent/molecule/2.2.0/molecule.yml @@ -5,8 +5,19 @@ dependency: driver: name: docker platforms: - - name: ubuntu2004 - image: geerlingguy/docker-ubuntu2004-ansible + ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. + # - name: ubuntu2004 + # image: geerlingguy/docker-ubuntu2004-ansible + # command: ${MOLECULE_DOCKER_COMMAND:-""} + # cgroupns_mode: host + # tmpfs: + # - /run + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:rw + # privileged: true + # pre_build_image: true + - name: ubuntu2204 + image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -15,8 +26,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: ubuntu2204 - image: geerlingguy/docker-ubuntu2204-ansible + - name: ubuntu2404 + image: geerlingguy/docker-ubuntu2404-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -45,16 +56,6 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - cgroupns_mode: host - tmpfs: - - /run - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - privileged: true - pre_build_image: true - name: rockylinux9 image: geerlingguy/docker-rockylinux9-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/molecule/2.3.0/converge.yml b/roles/agent/molecule/2.3.0/converge.yml index 6fa62fce9..54ff31445 100644 --- a/roles/agent/molecule/2.3.0/converge.yml +++ b/roles/agent/molecule/2.3.0/converge.yml @@ -17,8 +17,17 @@ loop: - apt-utils - man + - ufw when: ansible_os_family == 'Debian' + - name: Install prerequisites. + ansible.builtin.dnf: + name: "{{ item }}" + state: present + loop: + - firewalld + when: ansible_os_family == 'RedHat' + - name: Create '/usr/share/man/man8/' on Ubuntu. ansible.builtin.file: path: /usr/share/man/man8/ diff --git a/roles/agent/molecule/2.3.0/group_vars/all.yml b/roles/agent/molecule/2.3.0/group_vars/all.yml index b3f20ebc8..11a82eb53 100644 --- a/roles/agent/molecule/2.3.0/group_vars/all.yml +++ b/roles/agent/molecule/2.3.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.3.0p4" +checkmk_var_version: "2.3.0p5" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "mysite" checkmk_var_automation_user: "cmkadmin" @@ -28,8 +28,13 @@ checkmk_agent_add_host: 'true' checkmk_agent_discover: 'true' checkmk_agent_discover_max_parallel_tasks: 2 checkmk_agent_update: 'false' -checkmk_agent_tls: 'false' -checkmk_agent_configure_firewall: 'false' +checkmk_agent_tls: 'true' +checkmk_agent_configure_firewall: 'true' +checkmk_agent_configure_firewall_zone: 'public' +checkmk_agent_server_ips: + - 10.10.10.10 + - 172.16.16.16 + - 192.168.1.1 checkmk_agent_force_install: 'false' checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" diff --git a/roles/agent/molecule/2.3.0/molecule.yml b/roles/agent/molecule/2.3.0/molecule.yml index 26b1538bb..c95ee9721 100644 --- a/roles/agent/molecule/2.3.0/molecule.yml +++ b/roles/agent/molecule/2.3.0/molecule.yml @@ -5,8 +5,19 @@ dependency: driver: name: docker platforms: - - name: ubuntu2004 - image: geerlingguy/docker-ubuntu2004-ansible + ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. + # - name: ubuntu2004 + # image: geerlingguy/docker-ubuntu2004-ansible + # command: ${MOLECULE_DOCKER_COMMAND:-""} + # cgroupns_mode: host + # tmpfs: + # - /run + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:rw + # privileged: true + # pre_build_image: true + - name: ubuntu2204 + image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -15,8 +26,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: ubuntu2204 - image: geerlingguy/docker-ubuntu2204-ansible + - name: ubuntu2404 + image: geerlingguy/docker-ubuntu2404-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -45,16 +56,6 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - cgroupns_mode: host - tmpfs: - - /run - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - privileged: true - pre_build_image: true - name: rockylinux9 image: geerlingguy/docker-rockylinux9-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 78df40bb1..b1a80d255 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -47,17 +47,18 @@ - name: "{{ ansible_os_family }} Derivatives: Configure Firewall for Agent." when: checkmk_agent_configure_firewall | bool and "ufw.service" in ansible_facts.services block: - - name: "{{ ansible_os_family }} Derivatives: Check if checkmk_agent_server is an IP address." + - name: "{{ ansible_os_family }} Derivatives: Add Checkmk Server to Firewall Whitelist if it is an IP address." + when: checkmk_agent_server | ansible.utils.ipaddr() ansible.builtin.set_fact: - checkmk_agent_server_ip: "{{ checkmk_agent_server }}" - when: checkmk_agent_server_ip is not defined and checkmk_agent_server | ansible.utils.ipaddr() + checkmk_agent_server_ips: "{{ checkmk_agent_server_ips + [checkmk_agent_server] }}" - name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent." + when: checkmk_agent_server_ips is defined community.general.ufw: rule: allow proto: tcp - src: "{{ checkmk_agent_server_ip }}" + src: "{{ item }}" port: '6556' comment: Allow Checkmk - when: checkmk_agent_server_ip is defined + loop: "{{ checkmk_agent_server_ips }}" become: true diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index ada672a3b..b3711add3 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -1,7 +1,7 @@ --- - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true - ansible.builtin.yum: + ansible.builtin.dnf: name: "{{ checkmk_agent_agent.file.host }}" state: present disable_gpg_check: true @@ -13,7 +13,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true - ansible.builtin.yum: + ansible.builtin.dnf: name: "{{ checkmk_agent_agent.file.cee }}" state: present disable_gpg_check: true @@ -36,7 +36,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true - ansible.builtin.yum: + ansible.builtin.dnf: name: "{{ checkmk_agent_agent.file.cre }}" state: present disable_gpg_check: true @@ -47,17 +47,18 @@ - name: "{{ ansible_os_family }} Derivatives: Configure Firewall for Agent." when: checkmk_agent_configure_firewall | bool and "firewalld.service" in ansible_facts.services block: - - name: "{{ ansible_os_family }} Derivatives: Check if checkmk_agent_server is an IP address." + - name: "{{ ansible_os_family }} Derivatives: Add Checkmk Server to Firewall Whitelist if it is an IP address." + when: checkmk_agent_server | ansible.utils.ipaddr() ansible.builtin.set_fact: - checkmk_agent_server_ip: "{{ checkmk_agent_server }}" - when: checkmk_agent_server_ip is not defined and checkmk_agent_server | ansible.utils.ipaddr() + checkmk_agent_server_ips: "{{ checkmk_agent_server_ips + [checkmk_agent_server] }}" - name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent." + when: checkmk_agent_server_ips is defined ansible.posix.firewalld: permanent: 'yes' immediate: 'yes' state: enabled - rich_rule: 'rule family="ipv4" source address={{ checkmk_agent_server_ip }} port port="{{ checkmk_agent_port }}" protocol="tcp" accept' + rich_rule: 'rule family="ipv4" source address={{ item }} port port="{{ checkmk_agent_port }}" protocol="tcp" accept' zone: "{{ checkmk_agent_configure_firewall_zone | default('public') }}" - when: checkmk_agent_server_ip is defined + loop: "{{ checkmk_agent_server_ips }}" become: true diff --git a/roles/server/README.md b/roles/server/README.md index bdfdb14f1..eee968357 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.3.0p4" + checkmk_server_version: "2.3.0p5" 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 dc4c78fd1..d28f50157 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -23,8 +23,9 @@ checkmk_server_server_stable_os: - Ubuntu-18 - Ubuntu-20 - Ubuntu-22 + - Ubuntu-24 -checkmk_server_version: "2.3.0p4" +checkmk_server_version: "2.3.0p5" checkmk_server_edition: cre checkmk_server_verify_setup: 'true' diff --git a/roles/server/molecule/2.1.0/molecule.yml b/roles/server/molecule/2.1.0/molecule.yml index 26b1538bb..e5016e217 100644 --- a/roles/server/molecule/2.1.0/molecule.yml +++ b/roles/server/molecule/2.1.0/molecule.yml @@ -45,16 +45,6 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - cgroupns_mode: host - tmpfs: - - /run - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - privileged: true - pre_build_image: true - name: rockylinux9 image: geerlingguy/docker-rockylinux9-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/server/molecule/2.2.0/molecule.yml b/roles/server/molecule/2.2.0/molecule.yml index 26b1538bb..694add3be 100644 --- a/roles/server/molecule/2.2.0/molecule.yml +++ b/roles/server/molecule/2.2.0/molecule.yml @@ -25,8 +25,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: debian11 - image: geerlingguy/docker-debian11-ansible + - name: ubuntu2404 + image: geerlingguy/docker-ubuntu2404-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -35,8 +35,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: debian12 - image: geerlingguy/docker-debian12-ansible + - name: debian11 + image: geerlingguy/docker-debian11-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -45,8 +45,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible + - name: debian12 + image: geerlingguy/docker-debian12-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: diff --git a/roles/server/molecule/2.3.0/group_vars/all.yml b/roles/server/molecule/2.3.0/group_vars/all.yml index bd9bfe0f4..e2459864d 100644 --- a/roles/server/molecule/2.3.0/group_vars/all.yml +++ b/roles/server/molecule/2.3.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.3.0p4" +checkmk_var_version: "2.3.0p5" 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.3.0/molecule.yml b/roles/server/molecule/2.3.0/molecule.yml index 26b1538bb..694add3be 100644 --- a/roles/server/molecule/2.3.0/molecule.yml +++ b/roles/server/molecule/2.3.0/molecule.yml @@ -25,8 +25,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: debian11 - image: geerlingguy/docker-debian11-ansible + - name: ubuntu2404 + image: geerlingguy/docker-ubuntu2404-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -35,8 +35,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: debian12 - image: geerlingguy/docker-debian12-ansible + - name: debian11 + image: geerlingguy/docker-debian11-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: @@ -45,8 +45,8 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:rw privileged: true pre_build_image: true - - name: centos8 - image: geerlingguy/docker-centos8-ansible + - name: debian12 + image: geerlingguy/docker-debian12-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host tmpfs: diff --git a/roles/server/tasks/RedHat.yml b/roles/server/tasks/RedHat.yml index 94685ff74..ecce0dd66 100644 --- a/roles/server/tasks/RedHat.yml +++ b/roles/server/tasks/RedHat.yml @@ -26,7 +26,7 @@ - name: "Install epel-release from URL on CentOS & RHEL 8." become: true - ansible.builtin.yum: + ansible.builtin.dnf: name: "{{ checkmk_server_epel_url }}" state: present disable_gpg_check: "{{ not checkmk_server_epel_gpg_check | bool }}" @@ -79,7 +79,7 @@ - name: "Install Checkmk Server." when: not 'check-mk-' + checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages become: true - ansible.builtin.yum: + ansible.builtin.dnf: name: "/tmp/{{ checkmk_server_setup_file }}" state: present disable_gpg_check: '{{ not checkmk_server_verify_setup | bool }}' diff --git a/scripts/release.sh b/scripts/release.sh index fc3fc168a..bd5ae53ac 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -17,7 +17,7 @@ collection_dir="${script_dir%/*}" # Update these as necessary: checkmk_ancient="2.1.0p44" checkmk_oldstable="2.2.0p27" -checkmk_stable="2.3.0p4" +checkmk_stable="2.3.0p5" 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 3d4fb4baa..1fd76dde8 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - version: "2.2.0p27" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 89a1a609f..9b1d69f8c 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -1,6 +1,6 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - version: "2.2.0p27" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index 9c6ae2fe6..9af32b735 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.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/discovery/tasks/test.yml b/tests/integration/targets/discovery/tasks/test.yml index 58de6e161..bc99f6879 100644 --- a/tests/integration/targets/discovery/tasks/test.yml +++ b/tests/integration/targets/discovery/tasks/test.yml @@ -72,7 +72,7 @@ automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" - state: "update_service_labels" + state: "only_service_labels" delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_hosts }}" @@ -95,19 +95,17 @@ failed_when: "'State is not supported before 2.3.0' not in monitorundecidedservices_output.msg" when: "not '2.3.0' in outer_item.version" - - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update service labels. (Should fail in 2.3.0)" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update service labels." discovery: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" - state: "update_service_labels" + state: "only_service_labels" delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_hosts }}" - register: stableupdateservicelabels_output - failed_when: "'State can only be used in bulk mode' not in stableupdateservicelabels_output.msg" when: "'2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Monitor undecided services. (Should fail in 2.3.0)" @@ -245,7 +243,7 @@ automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" - state: "update_service_labels" + state: "only_service_labels" bulk_size: 5 delegate_to: localhost register: bulkupdateservicelabels_output @@ -273,7 +271,7 @@ automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" - state: "update_service_labels" + state: "only_service_labels" bulk_size: 5 delegate_to: localhost when: "'2.3.0' in outer_item.version" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index 337eff8f6..b3b03d38a 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index 92d8d3d46..8c4301d99 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 2dde7c289..8b611a37e 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index e8277ac9c..db80bc402 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - version: "2.2.0p27" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index 12c578d2d..780d6adcf 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_bakery/vars/main.yml b/tests/integration/targets/lookup_bakery/vars/main.yml index 189e4a19f..d11082443 100644 --- a/tests/integration/targets/lookup_bakery/vars/main.yml +++ b/tests/integration/targets/lookup_bakery/vars/main.yml @@ -1,6 +1,6 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index c697f852c..62c0680a6 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index a415ce9ae..c747dd8de 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index 1737e4cde..b88415831 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index 37e1f2cd1..117af9770 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_rules/vars/main.yml b/tests/integration/targets/lookup_rules/vars/main.yml index fcb7bd686..f7aa3234c 100644 --- a/tests/integration/targets/lookup_rules/vars/main.yml +++ b/tests/integration/targets/lookup_rules/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_rulesets/vars/main.yml b/tests/integration/targets/lookup_rulesets/vars/main.yml index 20e901e4a..51efe5775 100644 --- a/tests/integration/targets/lookup_rulesets/vars/main.yml +++ b/tests/integration/targets/lookup_rulesets/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 4e1de009d..2f18253b6 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index 73b304256..93100f1dc 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index bce2ba34f..7e50b4759 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -1,4 +1,7 @@ --- +- name: "Include Checkmk version specific Variables." + ansible.builtin.include_vars: "{{ outer_item.version | regex_search('^[0-9]+[.][0-9]+[.][0-9]+') }}.yml" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules." rule: server_url: "{{ checkmk_var_server_url }}" @@ -63,16 +66,16 @@ rule: rule_id: "{{ item.content.id }}" conditions: "{{ item.content.extensions.conditions }}" - properties: - comment: "{{ item.content.extensions.properties.comment | default('') }}" - description: "New description" - value_raw: "{{ item.content.extensions.value_raw }}" + properties: + comment: "{{ item.content.extensions.properties.comment | default('') }}" + description: "New description" + value_raw: "{{ item.content.extensions.value_raw | string }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ created_rules.results }}" loop_control: - label: "{{ item.content.id }}" + label: "{{ item.content.id }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules. Again." rule: @@ -84,16 +87,16 @@ rule: rule_id: "{{ item.content.id }}" conditions: "{{ item.content.extensions.conditions }}" - properties: - comment: "{{ item.content.extensions.properties.comment | default('') }}" - description: "New description" - value_raw: "{{ item.content.extensions.value_raw }}" + properties: + comment: "{{ item.content.extensions.properties.comment | default('') }}" + description: "New description" + value_raw: "{{ item.content.extensions.value_raw | string }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ created_rules.results }}" loop_control: - label: "{{ item.content.id }}" + label: "{{ item.content.id }}" register: rule_result - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler @@ -113,25 +116,23 @@ rule: rule_id: "{{ item.id }}" conditions: "{{ item.extensions.conditions }}" - properties: - comment: "{{ item.extensions.properties.comment }}" - description: "Even newer description" - value_raw: "{{ item.extensions.value_raw }}" + properties: + comment: "{{ item.extensions.properties.comment }}" + description: "Even newer description" + value_raw: "{{ item.extensions.value_raw | string }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ lookup('checkmk.general.rules', + loop: "{{ lookup('checkmk.general.rules', ruleset='checkgroup_parameters:filesystem', comment_regex='Ansible managed', server_url=checkmk_var_server_url, site=outer_item.site, automation_user=checkmk_var_automation_user, automation_secret=checkmk_var_automation_secret, - validate_certs=False - ) - }}" + validate_certs=False) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: @@ -147,7 +148,7 @@ run_once: true # noqa run-once[task] loop: "{{ created_rules.results }}" loop_control: - label: "{{ item.content.id }}" + label: "{{ item.content.id }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -161,7 +162,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules. Again." rule: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" @@ -175,7 +176,7 @@ run_once: true # noqa run-once[task] loop: "{{ created_rules.results }}" loop_control: - label: "{{ item.content.id }}" + label: "{{ item.content.id }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler ansible.builtin.fail: @@ -183,46 +184,3 @@ when: "rule_result.changed" delegate_to: localhost run_once: true # noqa run-once[task] - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules. Oldschool." - 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: "{{ item.rule }}" - state: "present" - delegate_to: localhost - run_once: true # noqa run-once[task] - loop: "{{ checkmk_var_rules }}" - register: created_rules - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules again. Oldschool." - 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: "{{ item.rule }}" - state: "present" - delegate_to: localhost - run_once: true # noqa run-once[task] - loop: "{{ checkmk_var_rules }}" - register: created_rules - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - New label conditions." - 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: "{{ item.rule }}" - state: "present" - delegate_to: localhost - run_once: true # noqa run-once[task] - loop: "{{ checkmk_var_rules_230 }}" - register: created_rules - when: "'2.3' in outer_item.version" diff --git a/tests/integration/targets/rule/vars/2.1.0.yml b/tests/integration/targets/rule/vars/2.1.0.yml new file mode 100644 index 000000000..8a96fd72a --- /dev/null +++ b/tests/integration/targets/rule/vars/2.1.0.yml @@ -0,0 +1,109 @@ +--- +checkmk_var_rules: + - name: "Filesystems (used space and growth) - Magic Factor." + ruleset: "checkgroup_parameters:filesystem" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'magic': 0.8}" + + - name: "CPU load (not utilization!) - 15 minute load." + ruleset: "checkgroup_parameters:cpu_load" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'levels': (1.0, 2.0)}" + + - name: "CPU utilization on Linux/UNIX - Multiple thresholds." + ruleset: "checkgroup_parameters:cpu_iowait" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'core_util_time': (100.0, 300, 900), 'core_util_time_total': (100.0, 300, 900)}" + + - name: "Logwatch Event Console Forwarding - Multiple values." + ruleset: "checkgroup_parameters:logwatch_ec" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "", + "description": "", + "disabled": false + } + value_raw: "{'facility': 17, 'method': '', 'monitor_logfilelist': False}" + + - name: "Simulating SNMP by using a stored SNMP walk - Enable." + ruleset: "usewalk_hosts" + rule: + conditions: { + "host_labels": [], + "host_tags": [ + { + "key": "snmp_ds", + "operator": "is_not", + "value": "no-snmp" + } + ], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "disabled": false, + } + value_raw: 'True' + + - name: "Memory percentage used - Levels." + ruleset: "checkgroup_parameters:memory_percentage_used" + rule: + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "Warning at 80%\nCritical at 90%\n", + "description": "Allow higher memory usage", + "disabled": false, + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + } + value_raw: "{'levels': (80.0, 90.0)}" diff --git a/tests/integration/targets/rule/vars/2.2.0.yml b/tests/integration/targets/rule/vars/2.2.0.yml new file mode 100644 index 000000000..8a96fd72a --- /dev/null +++ b/tests/integration/targets/rule/vars/2.2.0.yml @@ -0,0 +1,109 @@ +--- +checkmk_var_rules: + - name: "Filesystems (used space and growth) - Magic Factor." + ruleset: "checkgroup_parameters:filesystem" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'magic': 0.8}" + + - name: "CPU load (not utilization!) - 15 minute load." + ruleset: "checkgroup_parameters:cpu_load" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'levels': (1.0, 2.0)}" + + - name: "CPU utilization on Linux/UNIX - Multiple thresholds." + ruleset: "checkgroup_parameters:cpu_iowait" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'core_util_time': (100.0, 300, 900), 'core_util_time_total': (100.0, 300, 900)}" + + - name: "Logwatch Event Console Forwarding - Multiple values." + ruleset: "checkgroup_parameters:logwatch_ec" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "", + "description": "", + "disabled": false + } + value_raw: "{'facility': 17, 'method': '', 'monitor_logfilelist': False}" + + - name: "Simulating SNMP by using a stored SNMP walk - Enable." + ruleset: "usewalk_hosts" + rule: + conditions: { + "host_labels": [], + "host_tags": [ + { + "key": "snmp_ds", + "operator": "is_not", + "value": "no-snmp" + } + ], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "disabled": false, + } + value_raw: 'True' + + - name: "Memory percentage used - Levels." + ruleset: "checkgroup_parameters:memory_percentage_used" + rule: + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "Warning at 80%\nCritical at 90%\n", + "description": "Allow higher memory usage", + "disabled": false, + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + } + value_raw: "{'levels': (80.0, 90.0)}" diff --git a/tests/integration/targets/rule/vars/2.3.0.yml b/tests/integration/targets/rule/vars/2.3.0.yml new file mode 100644 index 000000000..07f6ee6ee --- /dev/null +++ b/tests/integration/targets/rule/vars/2.3.0.yml @@ -0,0 +1,152 @@ +--- +checkmk_var_rules: + - name: "Filesystems (used space and growth) - Magic Factor." + ruleset: "checkgroup_parameters:filesystem" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'magic': 0.8}" + + - name: "CPU load (not utilization!) - 15 minute load." + ruleset: "checkgroup_parameters:cpu_load" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'levels15': (1.0, 2.0)}" + + - name: "CPU utilization on Linux/UNIX - Multiple thresholds." + ruleset: "checkgroup_parameters:cpu_iowait" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "description": "", + "disabled": false + } + value_raw: "{'core_util_time': (100.0, 300, 900), 'core_util_time_total': (100.0, 300, 900)}" + + - name: "Logwatch Event Console Forwarding - Multiple values." + ruleset: "checkgroup_parameters:logwatch_ec" + rule: + location: + folder: "/" + position: "bottom" + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "", + "description": "", + "disabled": false + } + value_raw: "{'facility': 17, 'method': '', 'monitor_logfilelist': False}" + + - name: "Simulating SNMP by using a stored SNMP walk - Enable." + ruleset: "usewalk_hosts" + rule: + conditions: { + "host_labels": [], + "host_tags": [ + { + "key": "snmp_ds", + "operator": "is_not", + "value": "no-snmp" + } + ], + "service_labels": [] + } + properties: { + "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", + "disabled": false, + } + value_raw: 'True' + + - name: "Memory percentage used - Levels." + ruleset: "checkgroup_parameters:memory_percentage_used" + rule: + conditions: { + "host_labels": [], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "Warning at 80%\nCritical at 90%\n", + "description": "Allow higher memory usage", + "disabled": false, + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + } + value_raw: "{'levels': (80.0, 90.0)}" + + - name: "Memory percentage used - Combined host label conditions." + ruleset: "checkgroup_parameters:memory_percentage_used" + rule: + conditions: { + "host_label_groups": [ + { + operator: "and", + label_group: [ + { + operator: "and", + label: "cmk/site:beta" + }, + { + operator: "or", + label: "cmk/os_family:linux" + } + ], + }, + { + operator: "or", + label_group: [ + { + operator: "and", + label: "cmk/site:alpha" + }, + { + operator: "or", + label: "cmk/os_family:windows" + } + ], + }, + ], + "host_tags": [], + "service_labels": [] + } + properties: { + "comment": "Warning at 70%\nCritical at 80%\n", + "description": "Allow higher memory usage for certain host label conditions", + "disabled": false, + "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" + } + value_raw: "{'levels': (70.0, 80.0)}" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 7002b3023..2f18253b6 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" @@ -12,153 +12,3 @@ test_sites: - version: "2.1.0p44" edition: "cre" site: "ancient_cre" - -checkmk_var_rules: - - name: "Filesystem - Magic Factor." - ruleset: "checkgroup_parameters:filesystem" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'magic': 0.8}" - - - name: "CPU - Load." - ruleset: "checkgroup_parameters:cpu_load" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'levels': (1.0, 2.0)}" - - - name: "CPU - Utilization." - ruleset: "checkgroup_parameters:cpu_iowait" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'core_util_time': (100.0, 300, 900), 'core_util_time_total': (100.0, 300, 900)}" - - - name: "Logwatch - Event Console Forwarding." - ruleset: "checkgroup_parameters:logwatch_ec" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "", - "description": "", - "disabled": false - } - value_raw: "{'facility': 17, 'method': '', 'monitor_logfilelist': False}" - - - ruleset: "usewalk_hosts" - rule: - conditions: { - "host_labels": [], - "host_tags": [ - { - "key": "snmp_ds", - "operator": "is_not", - "value": "no-snmp" - } - ], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "disabled": false, - } - value_raw: 'True' - - - ruleset: "checkgroup_parameters:memory_percentage_used" - rule: - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "Warning at 80%\nCritical at 90%\n", - "description": "Allow higher memory usage", - "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" - } - value_raw: "{'levels': (80.0, 90.0)}" - -checkmk_var_rules_230: - - ruleset: "checkgroup_parameters:memory_percentage_used" - rule: - conditions: { - "host_label_groups": [ - { - operator: "and", - label_group: [ - { - operator: "and", - label: "cmk/site:beta" - }, - { - operator: "or", - label: "cmk/os_family:linux" - } - ], - }, - { - operator: "or", - label_group: [ - { - operator: "and", - label: "cmk/site:alpha" - }, - { - operator: "or", - label: "cmk/os_family:windows" - } - ], - }, - ], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "Warning at 70%\nCritical at 80%\n", - "description": "Allow higher memory usage for certain host label conditions", - "disabled": false, - "documentation_url": "https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rules.py" - } - value_raw: "{'levels': (70.0, 80.0)}" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index 53340f522..62ebec255 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index 02a80145d..9e46f3e48 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index 6e82436cf..566913f02 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -1,9 +1,9 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" diff --git a/tests/integration/targets/user/tasks/test.yml b/tests/integration/targets/user/tasks/test.yml index dac472c7e..041fdbe66 100644 --- a/tests/integration/targets/user/tasks/test.yml +++ b/tests/integration/targets/user/tasks/test.yml @@ -203,44 +203,6 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test create with short pw for 2.3 (should fail)" - user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - server_url: "{{ checkmk_var_server_url }}" - site: "{{ outer_item.site }}" - automation_user: "{{ checkmk_var_automation_user }}" - automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - name: "autotest" - fullname: "autotest" - auth_type: "automation" - password: "2short" - roles: - - admin - state: "present" - delegate_to: localhost - run_once: true # noqa run-once[task] - when: "'2.3' in outer_item.version" - register: checkmk_shortpwcheck_create - failed_when: "'Please enter an automation secret of at least 10 characters.' not in checkmk_shortpwcheck_create.msg" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test reset with short pw for 2.3 (should fail)" - user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - server_url: "{{ checkmk_var_server_url }}" - site: "{{ outer_item.site }}" - automation_user: "{{ checkmk_var_automation_user }}" - automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - name: "{{ item.name }}" - password: "{{ item.password }}" - auth_type: "{{ item.auth_type }}" - state: "reset_password" - delegate_to: localhost - run_once: true # noqa run-once[task] - loop: "{{ checkmk_var_users_new_short_pw }}" - when: "'2.3' in outer_item.version" - register: checkmk_shortpwcheck_edit - failed_when: "'Password too short. For 2.3 and higher' not in checkmk_shortpwcheck_edit.msg" - - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module server_url: "{{ checkmk_var_server_url }}" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 4bbd14f24..c3db47f91 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -1,12 +1,12 @@ --- test_sites: - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cme" site: "stable_cme" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cee" site: "stable_cee" - - version: "2.3.0p4" + - version: "2.3.0p5" edition: "cre" site: "stable_cre" - version: "2.2.0p27" @@ -108,11 +108,6 @@ checkmk_var_users_newpw: password: "abcdefghij" auth_type: automation -checkmk_var_users_new_short_pw: - - name: user3 - password: "abcdefg" - auth_type: password - checkmk_var_users_edit: - name: admin1 fullname: Admin Eins