diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fc6e7a3b3..c8ad39b7b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,7 @@ jobs: - name: Create Release and upload Assets id: create-release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }} draft: false diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ea37fcde..3ad55d034 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,46 @@ checkmk.general Release Notes .. contents:: Topics +v4.3.1 +====== + +Release Summary +--------------- + +Bugfix Release. + +Bugfixes +-------- + +- Rule module - Fix empty rule conditions. + +v4.3.0 +====== + +Release Summary +--------------- + +Reworking the CI, enhancing code quality and improving modules. + +Minor Changes +------------- + +- Folder module - Extend attribute management. Please refer to the module documentation for more details. +- Lookup modules - Enable usage of ini files, environment and inventory variables to configure basic settings for the lookup plugins, like e.g., the server_url or site alongside the authentication options. Refer to the module documentation for details. +- Rule module - Introduce rule_id to uniquely identify rules. This ID can be retrieved e.g., using the lookup plugin. Refer to the module documentation for further details. + +Bugfixes +-------- + +- Folder module - Fix idempotency when using "attributes" parameter for creating a folder. +- Folder module - Parents will be parsed properly now. This means, that parents given as a string will now be parsed as a list of one. +- Host module - Parents will be parsed properly now. This means, that parents given as a string will now be parsed as a list of one. +- User module - Fix bug, where an absent user was created, if 'reset_password' was used. + +Known Issues +------------ + +- Lookup modules - When using inventory variables to configure e.g., the server_url, it is not possible to assign other variables to these variables. This is a limitation of Ansble itself. v4.2.0 ====== @@ -604,7 +644,6 @@ Major Changes Minor Changes ------------- - v0.12.0 ======= diff --git a/README.md b/README.md index 5d32abd4e..4d2772925 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ Checkmk and keep your daily operations smooth and efficient. ## Here be dragons! This collection is provided AS IS and we cannot guarantee proper functionality. + Additionally, there is no commercial support whatsoever! + This is an open source endeavour, on which we want to collaborate with the community. [![Ansible Sanity Tests](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ansible-sanity-tests.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ansible-sanity-tests.yaml) @@ -42,6 +44,8 @@ Name | Description --> ### Lookup plugins +Click on the lookup plugin name below, to get detailed documentation about it. +For more in-depth documentation, see [this README](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/README.md). Name | Description | Tests --- | --- | --- @@ -57,6 +61,7 @@ Name | Description | Tests [checkmk.general.version](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/version.py)|Look up version and edition information.|[![Integration Tests for Version Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml) ### Modules +Click on the module name below, to get detailed documentation about it. Name | Description | Tests --- | --- | --- @@ -74,6 +79,7 @@ Name | Description | Tests [checkmk.general.user](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/user.py)|Manage users.|[![Integration Tests for User Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml) ### Roles +Click on the role name below, to get documentation about the role. Name | Description | Tests --- | --- | --- diff --git a/SUPPORT.md b/SUPPORT.md index 80ebb253a..0cfd59c95 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -49,3 +49,5 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 4.0.1 | 2.0.0p39, 2.1.0p36, 2.2.0p16 | 2.14, 2.15, 2.16 | None 4.1.0 | 2.0.0p39, 2.1.0p37, 2.2.0p17 | 2.14, 2.15, 2.16 | None 4.2.0 | 2.0.0p39, 2.1.0p38, 2.2.0p19 | 2.14, 2.15, 2.16 | None +4.3.0 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None +4.3.1 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 5dbfd4d98..eca74aa33 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -31,15 +31,15 @@ plugins: name: hosts version_added: 3.3.0 rule: - description: Show rule + description: Show a rule name: rule version_added: 3.5.0 rules: - description: List rules + description: Get a list rules name: rules version_added: 3.5.0 ruleset: - description: Show ruleset + description: Show a ruleset name: ruleset version_added: 3.5.0 rulesets: @@ -126,4 +126,4 @@ plugins: strategy: {} test: {} vars: {} -version: 4.2.0 +version: 4.3.1 diff --git a/changelogs/fragments/fix_folder_module_idempotency.yml b/changelogs/archive/4.3.0/fix_folder_module_idempotency.yml similarity index 100% rename from changelogs/fragments/fix_folder_module_idempotency.yml rename to changelogs/archive/4.3.0/fix_folder_module_idempotency.yml diff --git a/changelogs/archive/4.3.0/folder.yml b/changelogs/archive/4.3.0/folder.yml new file mode 100644 index 000000000..e95d55914 --- /dev/null +++ b/changelogs/archive/4.3.0/folder.yml @@ -0,0 +1,3 @@ +minor_changes: + - Folder module - Extend attribute management. Please refer to the module documentation + for more details. diff --git a/changelogs/archive/4.3.0/lookups.yml b/changelogs/archive/4.3.0/lookups.yml new file mode 100644 index 000000000..1c8d0172f --- /dev/null +++ b/changelogs/archive/4.3.0/lookups.yml @@ -0,0 +1,9 @@ +minor_changes: + - Lookup modules - Enable usage of ini files, environment and inventory variables + to configure basic settings for the lookup plugins, like e.g., the server_url or site + alongside the authentication options. Refer to the module documentation for details. + +known_issues: + - Lookup modules - When using inventory variables to configure e.g., the server_url, + it is not possible to assign other variables to these variables. + This is a limitation of Ansble itself. diff --git a/changelogs/archive/4.3.0/parents.yml b/changelogs/archive/4.3.0/parents.yml new file mode 100644 index 000000000..b979b09b5 --- /dev/null +++ b/changelogs/archive/4.3.0/parents.yml @@ -0,0 +1,5 @@ +bugfixes: + - Host module - Parents will be parsed properly now. + This means, that parents given as a string will now be parsed as a list of one. + - Folder module - Parents will be parsed properly now. + This means, that parents given as a string will now be parsed as a list of one. diff --git a/changelogs/archive/4.3.0/release_summary.yml b/changelogs/archive/4.3.0/release_summary.yml new file mode 100644 index 000000000..378cdb716 --- /dev/null +++ b/changelogs/archive/4.3.0/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Reworking the CI, enhancing code quality and improving modules." diff --git a/changelogs/archive/4.3.0/rule.yml b/changelogs/archive/4.3.0/rule.yml new file mode 100644 index 000000000..03b6872ef --- /dev/null +++ b/changelogs/archive/4.3.0/rule.yml @@ -0,0 +1,4 @@ +minor_changes: + - Rule module - Introduce rule_id to uniquely identify rules. + This ID can be retrieved e.g., using the lookup plugin. + Refer to the module documentation for further details. diff --git a/changelogs/archive/4.3.0/user.yml b/changelogs/archive/4.3.0/user.yml new file mode 100644 index 000000000..0d4ed82b5 --- /dev/null +++ b/changelogs/archive/4.3.0/user.yml @@ -0,0 +1,2 @@ +bugfixes: + - User module - Fix bug, where an absent user was created, if 'reset_password' was used. diff --git a/changelogs/archive/4.3.1/fix_rule_conditions_missing.yml b/changelogs/archive/4.3.1/fix_rule_conditions_missing.yml new file mode 100644 index 000000000..341b85838 --- /dev/null +++ b/changelogs/archive/4.3.1/fix_rule_conditions_missing.yml @@ -0,0 +1,2 @@ +bugfixes: + - Rule module - Fix empty rule conditions. diff --git a/changelogs/archive/4.3.1/release_summary.yml b/changelogs/archive/4.3.1/release_summary.yml new file mode 100644 index 000000000..b345fa2b5 --- /dev/null +++ b/changelogs/archive/4.3.1/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Bugfix Release." diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 27a17b96a..f4e51c674 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -823,3 +823,47 @@ releases: - tag_group.yml - user.yml release_date: '2024-01-23' + 4.3.0: + changes: + bugfixes: + - Folder module - Fix idempotency when using "attributes" parameter for creating + a folder. + - Folder module - Parents will be parsed properly now. This means, that parents + given as a string will now be parsed as a list of one. + - Host module - Parents will be parsed properly now. This means, that parents + given as a string will now be parsed as a list of one. + - User module - Fix bug, where an absent user was created, if 'reset_password' + was used. + known_issues: + - Lookup modules - When using inventory variables to configure e.g., the server_url, + it is not possible to assign other variables to these variables. This is a + limitation of Ansble itself. + minor_changes: + - Folder module - Extend attribute management. Please refer to the module documentation + for more details. + - Lookup modules - Enable usage of ini files, environment and inventory variables + to configure basic settings for the lookup plugins, like e.g., the server_url + or site alongside the authentication options. Refer to the module documentation + for details. + - Rule module - Introduce rule_id to uniquely identify rules. This ID can be + retrieved e.g., using the lookup plugin. Refer to the module documentation + for further details. + release_summary: Reworking the CI, enhancing code quality and improving modules. + fragments: + - fix_folder_module_idempotency.yml + - folder.yml + - lookups.yml + - parents.yml + - release_summary.yml + - rule.yml + - user.yml + release_date: '2024-02-16' + 4.3.1: + changes: + bugfixes: + - Rule module - Fix empty rule conditions. + release_summary: Bugfix Release. + fragments: + - fix_rule_conditions_missing.yml + - release_summary.yml + release_date: '2024-02-21' diff --git a/changelogs/template.yml b/changelogs/template.yml index 4931365a8..d4b43fd17 100644 --- a/changelogs/template.yml +++ b/changelogs/template.yml @@ -21,12 +21,20 @@ # For changes that are not really scoped (for example, which affect a whole collection), use the following format: # - Description starting with an uppercase letter and ending with a dot at the very end. Multiple sentences are allowed. +# Tipps: +# You can write multi line changelogs like this: +# - Module name - This is a very long and detailed +# changelog line, so we will split it into several +# lines, just like this. + ## Possible keys: # # release_summary # Adds a single line release summary to the changelog. # breaking_changes -# Changes that break existing playbooks or roles. This includes any change to existing behavior that forces users to update tasks. Displayed in both the changelogs and the Porting Guides. +# Changes that break existing playbooks or roles. +# This includes any change to existing behavior that forces users to update tasks. +# Displayed in both the changelogs and the Porting Guides. # major_changes # Major changes to Ansible itself. Generally does not include module or plugin changes. Displayed in both the changelogs and the Porting Guides. # minor_changes diff --git a/docs/activation_module.rst b/docs/activation_module.rst index 833b227a3..1897e6e4c 100644 --- a/docs/activation_module.rst +++ b/docs/activation_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.activation module -- Activate changes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -259,7 +259,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/bakery_lookup.rst b/docs/bakery_lookup.rst index 5aaac065f..520f10543 100644 --- a/docs/bakery_lookup.rst +++ b/docs/bakery_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.bakery lookup -- Get the bakery status of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -112,7 +112,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -149,7 +166,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -189,6 +223,23 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -223,7 +274,24 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -260,7 +328,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an
- Wether or not to validate TLS certificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -271,6 +339,23 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -288,6 +373,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -301,7 +387,7 @@ Examples - name: "Show bakery status" - debug: + ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: bakery: "{{ lookup('checkmk.general.bakery', @@ -312,6 +398,17 @@ Examples automation_secret=automation_secret )}}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Bakery status is {{ bakery }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + bakery: "{{ lookup('checkmk.general.bakery') }}" + diff --git a/docs/bakery_module.rst b/docs/bakery_module.rst index e67c155e1..796e6b8dc 100644 --- a/docs/bakery_module.rst +++ b/docs/bakery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.bakery module -- Trigger baking and signing in the agent bakery. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -174,7 +174,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/contact_group_module.rst b/docs/contact_group_module.rst index e8c39b575..87507af6e 100644 --- a/docs/contact_group_module.rst +++ b/docs/contact_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.contact_group module -- Manage contact groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/discovery_module.rst b/docs/discovery_module.rst index 41290fe02..ce3148de8 100644 --- a/docs/discovery_module.rst +++ b/docs/discovery_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.discovery module -- Discover services in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -368,7 +368,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/downtime_module.rst b/docs/downtime_module.rst index 71133f598..7d608a674 100644 --- a/docs/downtime_module.rst +++ b/docs/downtime_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.downtime module -- Manage downtimes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -402,7 +402,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst index e7b90605a..d0d332eb1 100644 --- a/docs/environment_variables.rst +++ b/docs/environment_variables.rst @@ -2,7 +2,7 @@ :orphan: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. _list_of_collection_env_vars: @@ -12,4 +12,78 @@ Index of all Collection Environment Variables The following index documents all environment variables declared by plugins in collections. Environment variables used by the ansible-core configuration are documented in :ref:`ansible_configuration_settings`. -No environment variables have been defined. +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET + + Automation secret for the REST API access. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER + + Automation user for the REST API access. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_SERVER_URL + + See the documentations for the options where this environment variable is used. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_SITE + + Site name. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` +.. envvar:: ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS + + Whether or not to validate TLS certificates. + + *Used by:* + :ansplugin:`checkmk.general.bakery lookup plugin `, + :ansplugin:`checkmk.general.folder lookup plugin `, + :ansplugin:`checkmk.general.folders lookup plugin `, + :ansplugin:`checkmk.general.host lookup plugin `, + :ansplugin:`checkmk.general.hosts lookup plugin `, + :ansplugin:`checkmk.general.rule lookup plugin `, + :ansplugin:`checkmk.general.rules lookup plugin `, + :ansplugin:`checkmk.general.ruleset lookup plugin `, + :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.version lookup plugin ` diff --git a/docs/folder_lookup.rst b/docs/folder_lookup.rst index 59945519e..bd263439a 100644 --- a/docs/folder_lookup.rst +++ b/docs/folder_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folder lookup -- Get folder attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -167,7 +167,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -204,7 +221,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -244,6 +278,23 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -278,7 +329,24 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -315,7 +383,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an
- Wether or not to validate TLS certificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -326,6 +394,23 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -342,6 +427,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.folder', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.folder', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -369,6 +458,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of folder /network: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" + diff --git a/docs/folder_module.rst b/docs/folder_module.rst index 2c3d68992..5152810c9 100644 --- a/docs/folder_module.rst +++ b/docs/folder_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folder module -- Manage folders in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -177,6 +177,48 @@ Parameters The automation user you want to use. It has to be an 'Automation' user, not a normal one. + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.folder_module__parameter-extended_functionality: + + .. rst-class:: ansible-option-title + + **extended_functionality** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Allow extended functionality instead of the expected REST API behavior. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + .. raw:: html
@@ -280,7 +322,7 @@ Parameters
- The remove\_attributes of your host as described in the API documentation. This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The remove\_attributes of your host as described in the API documentation. \ :strong:`If a list of strings is supplied, the listed attributes are removed.`\ \ :strong:`If extended\_functionality and a dict is supplied, the attributes that exactly match the passed attributes are removed.`\ This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. .. raw:: html @@ -314,7 +356,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/folders_lookup.rst b/docs/folders_lookup.rst index 243c341ba..1db6b14c1 100644 --- a/docs/folders_lookup.rst +++ b/docs/folders_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.folders lookup -- Get various information about a folder .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -168,7 +168,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -205,7 +222,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -290,6 +324,23 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -369,7 +420,24 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -406,7 +474,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -417,6 +485,23 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -433,6 +518,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.folders', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.folders', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -483,6 +572,24 @@ Examples loop_control: label: "{{ item.0.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Folder tree: {{ item.id }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.folders', + '~', + show_hosts=False, + recursive=True, + ) }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/host_group_module.rst b/docs/host_group_module.rst index 31633c1ce..58adb75b1 100644 --- a/docs/host_group_module.rst +++ b/docs/host_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host_group module -- Manage host groups in Checkmk (bulk version .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/host_lookup.rst b/docs/host_lookup.rst index 306a3a4dc..49035dad6 100644 --- a/docs/host_lookup.rst +++ b/docs/host_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host lookup -- Get host attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -167,7 +167,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -204,7 +221,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -289,6 +323,23 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -323,7 +374,24 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -360,7 +428,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -371,6 +439,23 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -387,6 +472,10 @@ Notes .. note:: - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: ``lookup('checkmk.general.host', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.host', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -415,6 +504,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of host example: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}" + diff --git a/docs/host_module.rst b/docs/host_module.rst index c0b8a4510..304716015 100644 --- a/docs/host_module.rst +++ b/docs/host_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.host module -- Manage hosts in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -318,7 +318,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/hosts_lookup.rst b/docs/hosts_lookup.rst index cdb4f881c..a4d661577 100644 --- a/docs/hosts_lookup.rst +++ b/docs/hosts_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.hosts lookup -- Get various information about a host .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -113,7 +113,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- automation secret for the REST API access + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret .. raw:: html @@ -150,7 +167,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- automation user for the REST API access + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user .. raw:: html @@ -235,6 +269,23 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and URL of the Checkmk server + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -269,7 +320,24 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -306,7 +374,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and
- Wether or not to validate TLS cerificates + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -317,6 +385,23 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -327,6 +412,14 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -355,6 +448,20 @@ Examples loop_control: label: "{{ item.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.hosts', effective_attributes=True) }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/index.rst b/docs/index.rst index 9e4033ad8..20fc5af31 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. _plugins_in_checkmk.general: @@ -9,7 +9,7 @@ Checkmk.General =============== -Collection version 4.2.0 +Collection version 4.3.1 .. contents:: :local: @@ -99,9 +99,9 @@ Lookup Plugins * :ansplugin:`folders lookup ` -- Get various information about a folder * :ansplugin:`host lookup ` -- Get host attributes * :ansplugin:`hosts lookup ` -- Get various information about a host -* :ansplugin:`rule lookup ` -- Show rule -* :ansplugin:`rules lookup ` -- List rules -* :ansplugin:`ruleset lookup ` -- Show ruleset +* :ansplugin:`rule lookup ` -- Show a rule +* :ansplugin:`rules lookup ` -- Get a list rules +* :ansplugin:`ruleset lookup ` -- Show a ruleset * :ansplugin:`rulesets lookup ` -- Search rulesets * :ansplugin:`version lookup ` -- Get the version of a Checkmk server diff --git a/docs/password_module.rst b/docs/password_module.rst index 3768602a1..f3c4a3010 100644 --- a/docs/password_module.rst +++ b/docs/password_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.password module -- Manage passwords in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -378,7 +378,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/rule_lookup.rst b/docs/rule_lookup.rst index 9c3651195..2f1740416 100644 --- a/docs/rule_lookup.rst +++ b/docs/rule_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.rule lookup -- Show rule -++++++++++++++++++++++++++++++++++++++++ +checkmk.general.rule lookup -- Show a rule +++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -226,6 +260,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -263,6 +314,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -297,7 +365,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -308,6 +376,23 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -318,6 +403,14 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -345,6 +438,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}" + diff --git a/docs/rule_module.rst b/docs/rule_module.rst index bd973c7bd..58a670819 100644 --- a/docs/rule_module.rst +++ b/docs/rule_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.rule module -- Manage rules in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -461,6 +461,50 @@ Parameters Properties of the rule. + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.rule_module__parameter-rule/rule_id: + + .. rst-class:: ansible-option-title + + **rule_id** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + If given, it will be \ :literal:`the only condition`\ to identify the rule to work on. + + When there's no rule found with this id, the task will fail. + + .. raw:: html
@@ -569,7 +613,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/rules_lookup.rst b/docs/rules_lookup.rst index 65409420e..ce6b14b53 100644 --- a/docs/rules_lookup.rst +++ b/docs/rules_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.rules lookup -- List rules -++++++++++++++++++++++++++++++++++++++++++ +checkmk.general.rules lookup -- Get a list rules +++++++++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -308,6 +342,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -345,6 +396,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -379,7 +447,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -390,6 +458,23 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -400,6 +485,14 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -446,6 +539,20 @@ Examples loop_control: label: "{{ item.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rules', ruleset='host_groups') }}" + loop_control: + label: "{{ item.id }}" + diff --git a/docs/ruleset_lookup.rst b/docs/ruleset_lookup.rst index 5d0df3cb3..2868af97d 100644 --- a/docs/ruleset_lookup.rst +++ b/docs/ruleset_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -17,13 +17,13 @@ .. Title -checkmk.general.ruleset lookup -- Show ruleset -++++++++++++++++++++++++++++++++++++++++++++++ +checkmk.general.ruleset lookup -- Show a ruleset +++++++++++++++++++++++++++++++++++++++++++++++++ .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -226,6 +260,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -263,6 +314,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -297,7 +365,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -308,6 +376,23 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -318,6 +403,14 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -345,6 +438,17 @@ Examples ) }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}" + diff --git a/docs/rulesets_lookup.rst b/docs/rulesets_lookup.rst index 3c1850bac..71febe03e 100644 --- a/docs/rulesets_lookup.rst +++ b/docs/rulesets_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.rulesets lookup -- Search rulesets .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -359,6 +393,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` URL of the Checkmk server. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + .. raw:: html
@@ -393,7 +444,24 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)``
- Site name + Site name. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site .. raw:: html @@ -430,7 +498,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)``
- Whether or not to validate TLS cerificates. + Whether or not to validate TLS certificates. .. rst-class:: ansible-option-line @@ -441,6 +509,23 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -451,6 +536,14 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` .. Notes +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -498,6 +591,20 @@ Examples loop_control: label: "{{ item.0.id }}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset {{ item.extension.name }} is deprecated." + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" + loop_control: + label: "{{ item.0.id }}" + diff --git a/docs/service_group_module.rst b/docs/service_group_module.rst index 23823acc0..248ca372e 100644 --- a/docs/service_group_module.rst +++ b/docs/service_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.service_group module -- Manage service groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -280,7 +280,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/tag_group_module.rst b/docs/tag_group_module.rst index 474bac84c..441a63269 100644 --- a/docs/tag_group_module.rst +++ b/docs/tag_group_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.tag_group module -- Manage tag groups in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -292,7 +292,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/timeperiod_module.rst b/docs/timeperiod_module.rst index 42d060689..11c8938eb 100644 --- a/docs/timeperiod_module.rst +++ b/docs/timeperiod_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.timeperiod module -- Manage time periods in checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -344,7 +344,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/user_module.rst b/docs/user_module.rst index 5ec6d55ce..cd72f8c1d 100644 --- a/docs/user_module.rst +++ b/docs/user_module.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.user module -- Manage users in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 4.2.0). + This module is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -975,7 +975,7 @@ Parameters
- The base url of your Checkmk server. + The base url of your Checkmk server including the protocol. .. raw:: html diff --git a/docs/version_lookup.rst b/docs/version_lookup.rst index 7f592e844..7d815c5a4 100644 --- a/docs/version_lookup.rst +++ b/docs/version_lookup.rst @@ -7,7 +7,7 @@ :trim: .. meta:: - :antsibull-docs: 2.6.1 + :antsibull-docs: 2.7.0 .. Anchors @@ -23,7 +23,7 @@ checkmk.general.version lookup -- Get the version of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 4.2.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 4.3.1). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -115,6 +115,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Automation secret for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + .. raw:: html
@@ -152,6 +169,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Automation user for the REST API access. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + .. raw:: html
@@ -186,7 +220,24 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a
- URL of the Checkmk server + URL of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url .. raw:: html @@ -226,6 +277,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a Site name. + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + .. raw:: html
@@ -271,6 +339,23 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + .. raw:: html
@@ -288,6 +373,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. .. Seealso @@ -311,6 +397,17 @@ Examples automation_secret=my_secret )}}" + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Server version is {{ version }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.version') }}" + diff --git a/galaxy.yml b/galaxy.yml index 8e1ad3332..f4f35b8cd 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ name: general # The version of the collection. Must be compatible with semantic versioning -version: 4.2.0 +version: 4.3.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/doc_fragments/common.py b/plugins/doc_fragments/common.py index d70c16134..d0ed25cd9 100644 --- a/plugins/doc_fragments/common.py +++ b/plugins/doc_fragments/common.py @@ -7,7 +7,7 @@ class ModuleDocFragment(object): DOCUMENTATION = r""" options: server_url: - description: The base url of your Checkmk server. + description: The base url of your Checkmk server including the protocol. required: true type: str site: diff --git a/plugins/lookup/README.md b/plugins/lookup/README.md new file mode 100644 index 000000000..c5b855619 --- /dev/null +++ b/plugins/lookup/README.md @@ -0,0 +1,57 @@ +# Lookup Plugins + +## Using variables for Lookup plugins +It is possible to set variables for authentication globally for lookup plugins. +This way, they do not need to be provided at task level. + +### Method 1: Environment variables +```bash +export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver" +export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite +export ANSIBLE_LOOKUP_AUTOMATION_USER=automation +export ANSIBLE_LOOKUP_AUTOMATION_SECRET=mysecret +export ANSIBLE_LOOKUP_VALIDATE_CERTS=False +``` + +### Method 2: In `ansible.cfg` +```ini +[checkmk_lookup] +server_url = https://myserver +site = mysite +automation_user = automation +automation_secret = mysecret +validate_certs = False + +``` + +### Method 3: In playbooks or the inventory +```yaml +- name: My Task + hosts: localhost + gather_facts: false + vars: + ansible_lookup_checkmk_server_url: "https://myserver" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_automation_user: "automation" + ansible_lookup_automation_secret: "mysecret" + ansible_lookup_validate_certs: false + + tasks: + - name: Get the attributes of myhost + ansible.builtin.debug: + msg: "Attributes of myhost: {{ attributes }}" + vars: + attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" +``` + +### Example +The following task will work, if one of the above methods has been applied. +```yaml +- name: My Task + tasks: + - name: Get the attributes of myhost + ansible.builtin.debug: + msg: "Attributes of myhost: {{ attributes }}" + vars: + attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" +``` diff --git a/plugins/lookup/bakery.py b/plugins/lookup/bakery.py index 0346e3122..6308bb351 100644 --- a/plugins/lookup/bakery.py +++ b/plugins/lookup/bakery.py @@ -79,11 +79,13 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ - name: "Show bakery status" - debug: + ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" vars: bakery: "{{ lookup('checkmk.general.bakery', @@ -93,6 +95,17 @@ automation_user=automation_user, automation_secret=automation_secret )}}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Bakery status is {{ bakery }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + bakery: "{{ lookup('checkmk.general.bakery') }}" """ RETURN = """ diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 56a204ca2..a2b5db1cd 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -100,6 +102,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of folder /network: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.folder', '~tests') }}" """ RETURN = """ diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index 8a3a9708a..4a18d7aaf 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -96,6 +96,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -136,6 +138,24 @@ loop: "{{ looping|subelements('members.hosts.value') }}" loop_control: label: "{{ item.0.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Folder tree: {{ item.id }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.folders', + '~', + show_hosts=False, + recursive=True, + ) }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/host.py b/plugins/lookup/host.py index a4145221d..af9a191fc 100644 --- a/plugins/lookup/host.py +++ b/plugins/lookup/host.py @@ -89,6 +89,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -107,6 +109,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Attributes of host example: {{ attributes }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}" """ RETURN = """ diff --git a/plugins/lookup/hosts.py b/plugins/lookup/hosts.py index 79f2e744e..50756e84a 100644 --- a/plugins/lookup/hosts.py +++ b/plugins/lookup/hosts.py @@ -86,6 +86,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -104,6 +106,20 @@ }}" loop_control: label: "{{ item.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.hosts', effective_attributes=True) }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/rule.py b/plugins/lookup/rule.py index 441b3ac71..105f39034 100644 --- a/plugins/lookup/rule.py +++ b/plugins/lookup/rule.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -100,6 +102,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}" """ RETURN = """ diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py index a9b954f8c..c36349ea7 100644 --- a/plugins/lookup/rules.py +++ b/plugins/lookup/rules.py @@ -93,6 +93,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -129,6 +131,20 @@ }}" loop_control: label: "{{ item.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Rule: {{ item.extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rules', ruleset='host_groups') }}" + loop_control: + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/ruleset.py b/plugins/lookup/ruleset.py index d25d1cb05..790fd7db9 100644 --- a/plugins/lookup/ruleset.py +++ b/plugins/lookup/ruleset.py @@ -83,6 +83,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -100,6 +102,17 @@ validate_certs=False ) }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}" """ RETURN = """ diff --git a/plugins/lookup/rulesets.py b/plugins/lookup/rulesets.py index 349920375..10acc985d 100644 --- a/plugins/lookup/rulesets.py +++ b/plugins/lookup/rulesets.py @@ -102,6 +102,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -139,6 +141,20 @@ }}" loop_control: label: "{{ item.0.id }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Ruleset {{ item.extension.name }} is deprecated." + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + loop: "{{ + lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" + loop_control: + label: "{{ item.0.id }}" """ RETURN = """ diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 5a87f4ded..389876af2 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -79,6 +79,8 @@ If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. """ EXAMPLES = """ @@ -92,6 +94,17 @@ automation_user=my_user, automation_secret=my_secret )}}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "Server version is {{ version }}" + vars: + ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}" + ansible_lookup_checkmk_site: "{{ outer_item.site }}" + ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}" + ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.version') }}" """ RETURN = """ diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 097acce4e..238dbd8cd 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -67,6 +67,11 @@ properties: description: Properties of the rule. type: dict + rule_id: + description: + - If given, it will be C(the only condition) to identify the rule to work on. + - When there's no rule found with this id, the task will fail. + type: str value_raw: description: Rule values as exported from the web interface. type: str @@ -284,20 +289,20 @@ def get_rules_in_ruleset(module, base_url, headers, ruleset): exit_failed( module, "Error calling API. HTTP code %d. Details: %s, " - % (info["status"], info["body"]), + % (info["status"], str(info)), ) - return json.loads(response.read().decode("utf-8")) + return json.loads(response.read().decode("utf-8")).get("value") def get_rule_by_id(module, base_url, headers, rule_id): api_endpoint = "/objects/rule/" + rule_id - url = base_url + api_endpoint + url = "%s%s" % (base_url, api_endpoint) response, info = fetch_url(module, url, headers=headers, method="GET") - if info["status"] not in [200, 204]: + if info["status"] != 200: exit_failed( module, "Error calling API. HTTP code %d. Details: %s, " @@ -308,8 +313,15 @@ def get_rule_by_id(module, base_url, headers, rule_id): def get_existing_rule(module, base_url, headers, ruleset, rule): - # Get rules in ruleset - rules = get_rules_in_ruleset(module, base_url, headers, ruleset) + if rule.get("rule_id"): + # We already know whih rule to get + if module.params.get("state") == "absent": + # When deleting and we already know the ID, don't compare + return rule.get("rule_id") + rules = [get_rule_by_id(module, base_url, headers, rule.get("rule_id"))] + else: + # Get rules in ruleset + rules = get_rules_in_ruleset(module, base_url, headers, ruleset) (value_mod, exc) = safe_eval(rule["value_raw"], include_exceptions=True) if exc is not None: @@ -324,7 +336,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): if rules is not None: # Loop through all rules - for r in rules.get("value"): + for r in rules: (value_api, exc) = safe_eval( r["extensions"]["value_raw"], include_exceptions=True ) @@ -338,7 +350,7 @@ def get_existing_rule(module, base_url, headers, ruleset, rule): and value_api == value_mod ): # If they are the same, return the ID - return r + return r["id"] return None @@ -347,9 +359,9 @@ def create_rule(module, base_url, headers, ruleset, rule): api_endpoint = "/domain-types/rule/collections/all" changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: - return (e["id"], not changed) + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + if rule_id: + return (rule_id, not changed) if module.check_mode: return (None, changed) @@ -380,12 +392,51 @@ def create_rule(module, base_url, headers, ruleset, rule): return (r["id"], changed) +def modify_rule(module, base_url, headers, ruleset, rule): + changed = True + rule_id = rule.get("rule_id") + + if not rule_id: + return not changed + + if get_existing_rule(module, base_url, headers, ruleset, rule): + return not changed + + if module.check_mode: + return (None, changed) + + headers["If-Match"] = get_rule_etag(module, base_url, headers, rule_id) + + params = { + "properties": rule["properties"], + "value_raw": rule["value_raw"], + "conditions": rule["conditions"], + } + + api_endpoint = "/objects/rule/" + rule_id + url = base_url + api_endpoint + + info = fetch_url( + module, url, module.jsonify(params), headers=headers, method="PUT" + )[1] + + if info["status"] not in [200, 204]: + exit_failed( + module, + "Error calling API. HTTP code %d. Details: %s, " + % (info["status"], info["body"]), + ) + + return changed + + def delete_rule(module, base_url, headers, ruleset, rule): changed = True - e = get_existing_rule(module, base_url, headers, ruleset, rule) - if e: + rule_id = get_existing_rule(module, base_url, headers, ruleset, rule) + + if rule_id: if not module.check_mode: - delete_rule_by_id(module, base_url, headers, e["id"]) + delete_rule_by_id(module, base_url, headers, rule_id) return changed return not changed @@ -471,6 +522,7 @@ def run_module(): conditions=dict(type="dict"), properties=dict(type="dict"), value_raw=dict(type="str"), + rule_id=dict(type="str"), location=dict( type="dict", options=dict( @@ -519,23 +571,24 @@ def run_module(): # Get the variables ruleset = module.params.get("ruleset", "") - rule = module.params.get("rule", "") + rule = module.params.get("rule", {}) location = rule.get("location") # Check if required params to create a rule are given - if rule.get("folder") is None or rule.get("folder") == "": + if not rule.get("folder"): rule["folder"] = location["folder"] - if rule.get("properties") is None or rule.get("properties") == "": - exit_failed(module, "Rule properties are required") - if rule.get("value_raw") is None or rule.get("value_raw") == "": - exit_failed(module, "Rule value_raw is required") - # Default to all hosts if conditions arent given - if rule.get("conditions") is None or rule.get("conditions") == "": - rule["conditions"] = { - "host_tags": [], - "host_labels": [], - "service_labels": [], - } + if not rule.get("rule_id"): + if not rule.get("properties"): + exit_failed(module, "Rule properties are required") + if not rule.get("value_raw"): + exit_failed(module, "Rule value_raw is required") + # Default to all hosts if conditions arent given + if not rule.get("conditions"): + rule["conditions"] = { + "host_tags": [], + "host_labels": [], + "service_labels": [], + } if module.params.get("state") == "absent": if location.get("rule_id") is not None: exit_failed(module, "rule_id in location is invalid with state=absent") @@ -549,13 +602,24 @@ def run_module(): exit_ok(module, "Rule does not exist") # If state is present, create the rule elif module.params.get("state") == "present": - (rule_id, created) = create_rule(module, base_url, headers, ruleset, rule) - if created: + action = None + if rule.get("rule_id"): + # Modify an existing rule + rule_id = rule.get("rule_id") + if modify_rule(module, base_url, headers, ruleset, rule): + action = "changed" + else: + # If no rule_id is mentioned, we check if our rule exists. If not, then create it. + (rule_id, changed) = create_rule(module, base_url, headers, ruleset, rule) + if changed: + action = "created" + + if action: # Move rule to specified location, if it's not default if location["position"] != "bottom" and not module.check_mode: move_rule(module, base_url, headers, rule_id, location) - exit_changed(module, "Rule created", rule_id) - exit_ok(module, "Rule already exists", rule_id) + exit_changed(module, "Rule %s" % action, rule_id) + exit_ok(module, "Rule already exists with equal settings", rule_id) # Fallback exit_failed(module, "Unknown error") diff --git a/roles/agent/README.md b/roles/agent/README.md index cb7d55538..d062dad65 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -13,7 +13,7 @@ It can be installed as easy as running: ## Role Variables - checkmk_agent_version: "2.2.0p22" + checkmk_agent_version: "2.2.0p23" The Checkmk version of the site your agents will talk to. @@ -64,12 +64,12 @@ The user used to authenticate against your Checkmk site. checkmk_agent_pass: my_secret -The password for the normal user used to authenticate against your Checkmk site, both for API calls and agent updates. +The password for the normal user used to authenticate against your Checkmk site, both for API calls and agent updates. This is mutually exclusive with `checkmk_agent_secret`. checkmk_agent_secret: my_secret -The secret for the automation user used to authenticate against your Checkmk site, both for API calls and agent updates. +The secret for the automation user used to authenticate against your Checkmk site, both for API calls and agent updates. This is mutually exclusive with `checkmk_agent_pass`. checkmk_agent_port: 6556 @@ -145,7 +145,7 @@ Enable this to automatically install `xinetd` on hosts with systemd prior to ver checkmk_agent_delegate_api_calls: localhost -Configure the host to which Checkmk API calls are delegated to. +Configure the host to which Checkmk API calls are delegated to. Typically this would be your Ansible host, hence the default `localhost`. checkmk_agent_delegate_download: "{{ inventory_hostname }}" @@ -155,8 +155,8 @@ Configure the host to which Checkmk API downloads are delegated to. After downlo checkmk_agent_mode: pull The mode the agent operates in. For most deployments, this will be the `pull` mode. -If you are uncertain, what you are using, this is most likely your mode. -If you are using an alternative way to call the agent, e.g. SSH, you can set the variable to `ssh`, so the agent port check is skipped. +If you are uncertain, what you are using, this is most likely your mode. +If you are using an alternative way to call the agent, e.g. SSH, you can set the variable to `ssh`, so the agent port check is skipped. If you are using the Checkmk Cloud Edition (CCE) with an agent in `push` mode, you want to set this to `push` to avoid the agent port check, as well as triggering an initial push of data. checkmk_agent_no_log: 'true' diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index d99c3a1f1..e43d0f13a 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_version: "2.2.0p22" +checkmk_agent_version: "2.2.0p23" checkmk_agent_edition: cre checkmk_agent_server_protocol: http checkmk_agent_server: localhost diff --git a/roles/agent/molecule/2.1.0/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index 23df43011..1437d561b 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p39" +checkmk_var_version: "2.1.0p40" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/agent/molecule/2.2.0/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index 2d9a1d6d6..6a8503c5c 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p22" +checkmk_var_version: "2.2.0p23" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "my_site" checkmk_var_automation_user: "cmkadmin" diff --git a/roles/server/README.md b/roles/server/README.md index 3d679da43..3cf7618f1 100644 --- a/roles/server/README.md +++ b/roles/server/README.md @@ -25,7 +25,7 @@ To learn about the distributions used in automated tests, inspect the correspond ## Role Variables - checkmk_server_version: "2.2.0p22" + checkmk_server_version: "2.2.0p23" The global Checkmk version. This is used for installing Checkmk. To manage sites and their version, see `checkmk_server_sites`. @@ -42,7 +42,7 @@ The edition you want to use. Valid values are `cre`, `cfe`, `cee`, `cce` and `cm For details about the editions see: https://checkmk.com/product/editions -Note, that you need credentials, to download the following editions: `cee` and `cme`. +Note, that you need credentials, to download the following editions: `cee` and `cme`. See below variables, to set those. checkmk_server_download_user: [] @@ -99,7 +99,7 @@ Valid choices include `install`, `keepold` and `abort`. Site configuration can be passed with the `omd_config` keyword. The format can be seen above, for a list of variables run `omd show` -on an existing site. +on an existing site. **Pay special attention to the `omd_auto_restart` variable!** As site configuration needs the site to be stopped, this needs to be handled. By default the variable is set to `false` to avoid unexpected restarting. However, no configuration will be performed if the site is started. checkmk_server_backup_on_update: 'true' diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 62e6dd721..a7a084093 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -24,7 +24,7 @@ checkmk_server_server_stable_os: - Ubuntu-20 - Ubuntu-22 -checkmk_server_version: "2.2.0p22" +checkmk_server_version: "2.2.0p23" checkmk_server_edition: cre checkmk_server_verify_setup: 'true' diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index 8baa9a637..62c495f0e 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p39" +checkmk_var_version: "2.1.0p40" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/molecule/2.2.0/group_vars/all.yml b/roles/server/molecule/2.2.0/group_vars/all.yml index 902bdc3ae..a65cf8c29 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p22" +checkmk_var_version: "2.2.0p23" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/scripts/release.sh b/scripts/release.sh index 01cb20fa8..58d7a2caf 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,8 +16,8 @@ collection_dir="${script_dir%/*}" # Update these as necessary: checkmk_ancient="2.0.0p39" -checkmk_oldstable="2.1.0p39" -checkmk_stable="2.2.0p22" +checkmk_oldstable="2.1.0p40" +checkmk_stable="2.2.0p23" checkmk_beta="2.3.0b1" while getopts 's:t:' OPTION; do diff --git a/tests/integration/files/includes/vars/global.yml b/tests/integration/files/includes/vars/global.yml index 57f8bb073..f243be9f5 100644 --- a/tests/integration/files/includes/vars/global.yml +++ b/tests/integration/files/includes/vars/global.yml @@ -15,3 +15,13 @@ checkmk_server_edition_mapping: cee: enterprise cce: cloud cme: managed + + +# This is a very hacky workaround, as it is not possible to assign variables +# to other variables when using them in lookup modules. +ansible_lookup_checkmk_server_url: "http://127.0.0.1" +ansible_lookup_checkmk_site: "stable_cee" # This is especially hacky. + # All integration tests were adapted to run the specific task only on this site. +ansible_lookup_checkmk_automation_user: "cmkadmin" +ansible_lookup_checkmk_automation_secret: "Sup3rSec4et!" +ansible_lookup_checkmk_validate_certs: false diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index d3d68b4e4..c6c8ddb11 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/bakery/tasks/main.yml b/tests/integration/targets/bakery/tasks/main.yml index bbb3963bc..de3aba5ec 100644 --- a/tests/integration/targets/bakery/tasks/main.yml +++ b/tests/integration/targets/bakery/tasks/main.yml @@ -5,6 +5,16 @@ - name: "Run Preparations." ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml +- name: "Inject a Key into the Sites." # This is a hack and should never be done in production! + ansible.builtin.copy: + src: agent_signature_keys.mk + dest: "/omd/sites/{{ item.site }}/etc/check_mk/multisite.d/wato/agent_signature_keys.mk" + owner: "{{ item.site }}" + group: "{{ item.site }}" + mode: "0660" + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" + - name: "Testing." ansible.builtin.include_tasks: test.yml loop: "{{ test_sites }}" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 1d3fd0265..da88042e1 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -3,10 +3,10 @@ test_sites: - version: "2.3.0b1" edition: "cme" site: "beta_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index bae95c104..eb9ee884a 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -6,13 +6,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index c610d0c55..2a8616f90 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index d3d68b4e4..c6c8ddb11 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index dbccfff06..bac92c431 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index e1b1af9f7..877e54bdb 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index 7ae741733..778396fa8 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -6,16 +6,16 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_bakery/tasks/test.yml b/tests/integration/targets/lookup_bakery/tasks/test.yml index b594758f0..a24572023 100644 --- a/tests/integration/targets/lookup_bakery/tasks/test.yml +++ b/tests/integration/targets/lookup_bakery/tasks/test.yml @@ -20,3 +20,15 @@ ("'initialized' in looked_up_bakery.msg") or ("'stopped' in looked_up_bakery.msg") or ("'exception' in looked_up_bakery.msg") + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: ("'finished' in bakery.msg") or + ("'running' in bakery.msg") or + ("'initialized' in bakery.msg") or + ("'stopped' in bakery.msg") or + ("'exception' in bakery.msg") + vars: + bakery: "{{ lookup('checkmk.general.bakery') }}" + delegate_to: localhost + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_bakery/vars/main.yml b/tests/integration/targets/lookup_bakery/vars/main.yml index a7e6724c0..a31e71c77 100644 --- a/tests/integration/targets/lookup_bakery/vars/main.yml +++ b/tests/integration/targets/lookup_bakery/vars/main.yml @@ -3,9 +3,9 @@ test_sites: - version: "2.3.0b1" edition: "cme" site: "beta_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cee" site: "old_cee" diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index 647dc014d..11522c352 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -57,3 +57,12 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "extensions.attributes.tag_criticality == checkmk_folder.criticality" + vars: + extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index 7f45fe088..f23b3d751 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index befebd766..f7109c8bc 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -14,7 +14,7 @@ run_once: true # noqa run-once[task] loop: "{{ checkmk_var_folders }}" -- name: "Get all folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all folders." ansible.builtin.debug: var: folders vars: @@ -30,7 +30,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "Get list of all folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get list of all folders." ansible.builtin.debug: msg: "Criticality of {{ item.id }} is {{ item.extensions.attributes.tag_criticality | default('N/A') }}" loop: "{{ lookup('checkmk.general.folders', @@ -47,7 +47,7 @@ loop_control: label: "{{ item.id }}" -- name: "Verify number of folders." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders." ansible.builtin.assert: # The looked up list contains the main folder, as well. that: "( 1 + checkmk_var_folders|length ) == folders|length" @@ -63,3 +63,13 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + # The looked up list contains the main folder, as well. + that: "( 1 + checkmk_var_folders|length ) == folders|length" + vars: + folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index b561788cd..f671d76b0 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index 281d673a0..c5f98fb5f 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -44,3 +44,12 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "checkmk_host.alias == extensions.attributes.alias" + vars: + extensions: "{{ lookup('checkmk.general.host', checkmk_host.name) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index eec67c94e..50a2ed338 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index 3e04d6b30..8642c7ad3 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -44,3 +44,12 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "checkmk_hosts|length == hosts|length" + vars: + folders: "{{ lookup('checkmk.general.hosts') }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index 69f410734..7b75b925e 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index 675237540..3baedaff3 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -68,7 +68,7 @@ vars: rules: "{{ lookup('checkmk.general.rules', ruleset=item, - commebt_regex='Ansible managed', + comment_regex='Ansible managed', server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -94,3 +94,24 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ cpu_load_ruleset.rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rule." + ansible.builtin.debug: + var: "rule" + vars: + rule: "{{ lookup('checkmk.general.rule', rule_id=item.id) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ cpu_load_ruleset.rules }}" + when: outer_item.edition == "stable_cee" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rules." + ansible.builtin.assert: + # Check the number of rules + that: rules|length == 1 + vars: + rules: "{{ lookup('checkmk.general.rules', ruleset=item, commebt_regex='Ansible managed') }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_rulesets }}" + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rules/vars/main.yml b/tests/integration/targets/lookup_rules/vars/main.yml index 409be699e..b42d58d5b 100644 --- a/tests/integration/targets/lookup_rules/vars/main.yml +++ b/tests/integration/targets/lookup_rules/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_rulesets/tasks/test.yml b/tests/integration/targets/lookup_rulesets/tasks/test.yml index 8f7482982..4055ea615 100644 --- a/tests/integration/targets/lookup_rulesets/tasks/test.yml +++ b/tests/integration/targets/lookup_rulesets/tasks/test.yml @@ -80,3 +80,23 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_ruleset_regexes }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: ruleset." + ansible.builtin.assert: + # For each rule that we created, check, if the number of rules in its ruleset is 1. + that: "ruleset.number_of_rules == 1" + vars: + ruleset: "{{ lookup('checkmk.general.ruleset', ruleset=item) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_ruleset_regexes }}" + when: outer_item.edition == "stable_cee" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rulesets." + ansible.builtin.debug: + var: rulesets + vars: + rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rulesets/vars/main.yml b/tests/integration/targets/lookup_rulesets/vars/main.yml index 3446899db..d445157d2 100644 --- a/tests/integration/targets/lookup_rulesets/vars/main.yml +++ b/tests/integration/targets/lookup_rulesets/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index e4409f64c..49dfb9ae7 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -16,3 +16,12 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify Checkmk version." ansible.builtin.assert: that: "outer_item.version in looked_up_version.msg" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." + ansible.builtin.assert: + that: "outer_item.version in looked_up_version.msg" + vars: + version: "{{ lookup('checkmk.general.version') }}" + delegate_to: localhost + register: looked_up_version + when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 1a0101feb..513e59a59 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index 645edfe25..6e5b267d1 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -6,16 +6,16 @@ test_sites: - version: "2.3.0b1" edition: "cme" site: "beta_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index b2f13c23c..f380dd7b0 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -45,6 +45,50 @@ delegate_to: localhost run_once: true # noqa run-once[task] +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules." + rule: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + ruleset: "{{ item.ruleset }}" + rule: + rule_id: "{{ existing_rule[0].id }}" + properties: { + "comment": "{{ existing_rule[0].extensions.properties.comment }}", + "description": "Modified this intentionally.", + "disabled": "{{ existing_rule[0].extensions.properties.disabled }}" + } + conditions: "{{ existing_rule[0].extensions.conditions }}" + value_raw: "{{ existing_rule[0].extensions.value_raw | string }}" + state: "present" + when: "existing_rule|length>0" + vars: + existing_rule: "{{ lookup('checkmk.general.rules', + ruleset=item.ruleset, + comment_regex='Ansible managed', + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + loop: "{{ checkmk_var_rules }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." + activation: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + force_foreign_changes: true + sites: + - "{{ outer_item.site }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: server_url: "{{ checkmk_var_server_url }}" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 5b1b25e52..c045815aa 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index b75722316..29c4efad3 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -6,16 +6,16 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index d18b737ac..9af589286 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -3,16 +3,16 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" - version: "2.0.0p39" diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index eccc0dc6a..e5ec8f2a1 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -3,13 +3,13 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 98311ba84..c9565e64b 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -6,16 +6,16 @@ test_sites: - version: "2.3.0b1" edition: "cre" site: "beta_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cme" site: "stable_cme" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p22" + - version: "2.2.0p23" edition: "cee" site: "stable_cee" - - version: "2.1.0p39" + - version: "2.1.0p40" edition: "cre" site: "old_cre"