From c0b0909b9587c11c3b46dcb09a936c492b2f19d6 Mon Sep 17 00:00:00 2001 From: Nicolas BRAINEZ Date: Fri, 10 Oct 2025 23:07:43 +0200 Subject: [PATCH 1/7] feat: Add aux_tag module --- changelogs/fragments/aux_tag_module.yml | 2 + plugins/modules/aux_tag.py | 244 ++++++++++++++++++ .../targets/aux_tag/tasks/main.yml | 35 +++ .../targets/aux_tag/tasks/test.yml | 102 ++++++++ 4 files changed, 383 insertions(+) create mode 100644 changelogs/fragments/aux_tag_module.yml create mode 100644 plugins/modules/aux_tag.py create mode 100644 tests/integration/targets/aux_tag/tasks/main.yml create mode 100644 tests/integration/targets/aux_tag/tasks/test.yml diff --git a/changelogs/fragments/aux_tag_module.yml b/changelogs/fragments/aux_tag_module.yml new file mode 100644 index 000000000..bd8491b3d --- /dev/null +++ b/changelogs/fragments/aux_tag_module.yml @@ -0,0 +1,2 @@ +minor_changes: + - aux_tag - New module to manage auxiliary tags in Checkmk. Auxiliary tags can be created, updated, and deleted independently, making it easier to manage tag hierarchies and dependencies. diff --git a/plugins/modules/aux_tag.py b/plugins/modules/aux_tag.py new file mode 100644 index 000000000..101293c3f --- /dev/null +++ b/plugins/modules/aux_tag.py @@ -0,0 +1,244 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# Copyright: (c) 2025, Nicolas Brainez +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: aux_tag + +short_description: Manage auxiliary tags in Checkmk. + +version_added: "6.3.0" + +description: +- Manage auxiliary tags in Checkmk. + +extends_documentation_fragment: [checkmk.general.common] + +options: + name: + description: The ID of the auxiliary tag. + required: true + type: str + aliases: ["id"] + + title: + description: The title of the auxiliary tag. + required: false + type: str + + topic: + description: The topic or category of the auxiliary tag. + required: false + type: str + + help: + description: Help text describing the auxiliary tag. + required: false + type: str + + state: + description: The desired state. + required: true + choices: ["present", "absent"] + type: str + +author: + - brainni (@brainni) +""" + +EXAMPLES = r""" +# Create an auxiliary tag +- name: "Create auxiliary tag for HTTPS" + checkmk.general.aux_tag: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + name: https + title: Web Server HTTPS + topic: Services + help: "Host provides HTTPS services" + state: "present" + +# Update an auxiliary tag +- name: "Update auxiliary tag" + checkmk.general.aux_tag: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + name: https + title: Web Server HTTPS/TLS + topic: Services + state: "present" + +# Delete an auxiliary tag +- name: "Delete auxiliary tag" + checkmk.general.aux_tag: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + name: https + state: "absent" +""" + +RETURN = r""" +http_code: + description: The HTTP code the Checkmk API returns. + type: int + returned: always + sample: '200' +message: + description: The output message that the module generates. + type: str + returned: always + sample: 'Done.' +""" + +import time + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.checkmk.general.plugins.module_utils.api import CheckmkAPI +from ansible_collections.checkmk.general.plugins.module_utils.types import RESULT +from ansible_collections.checkmk.general.plugins.module_utils.utils import ( + base_argument_spec, + result_as_dict, +) + +# We count 404 not as failed, because we want to know if the aux tag exists or not. +HTTP_CODES_GET = { + # http_code: (changed, failed, "Message") + 404: (False, False, "Not Found: The requested object has not been found."), +} + +HTTP_CODES_DELETE = { + # http_code: (changed, failed, "Message") + 404: (False, False, "Not Found: The requested object has not been found."), +} + + +class AuxTagCreateAPI(CheckmkAPI): + def post(self): # Create aux tag + data = { + "aux_tag_id": self.params.get("name", ""), + "title": self.params.get("title", ""), + "topic": self.params.get("topic", ""), + "help": self.params.get("help", ""), + } + + # Remove all keys without value, as otherwise they would be None. + data = {key: val for key, val in data.items() if val} + + return self._fetch( + endpoint="/domain-types/aux_tag/collections/all", + data=data, + method="POST", + ) + + +class AuxTagUpdateAPI(CheckmkAPI): + def put(self): # Update aux tag + data = { + "title": self.params.get("title", ""), + "topic": self.params.get("topic", ""), + "help": self.params.get("help", ""), + } + + # Remove all keys without value, as they would be emptied. + data = {key: val for key, val in data.items() if val} + + return self._fetch( + endpoint="/objects/aux_tag/%s" % self.params.get("name"), + data=data, + method="PUT", + ) + + +class AuxTagDeleteAPI(CheckmkAPI): + def delete(self): # Remove aux tag + return self._fetch( + code_mapping=HTTP_CODES_DELETE, + endpoint="/objects/aux_tag/%s" % self.params.get("name"), + method="DELETE", + ) + + +class AuxTagGetAPI(CheckmkAPI): + def get(self): + return self._fetch( + code_mapping=HTTP_CODES_GET, + endpoint="/objects/aux_tag/%s" % self.params.get("name"), + method="GET", + ) + + +def run_module(): + argument_spec = base_argument_spec() + argument_spec.update( + name=dict(type="str", required=True, aliases=["id"]), + title=dict(type="str", required=False), + topic=dict(type="str", required=False), + help=dict(type="str", required=False), + state=dict( + type="str", + choices=["present", "absent"], + required=True, + ), + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) + + result = RESULT( + http_code=0, + msg="Nothing to be done", + content="", + etag="", + failed=False, + changed=False, + ) + + if module.params.get("state") == "present": + auxtagget = AuxTagGetAPI(module) + result = auxtagget.get() + + if result.http_code == 200: + auxtagupdate = AuxTagUpdateAPI(module) + auxtagupdate.headers["If-Match"] = result.etag + result = auxtagupdate.put() + + time.sleep(3) + + elif result.http_code == 404: + auxtagcreate = AuxTagCreateAPI(module) + result = auxtagcreate.post() + + time.sleep(3) + + if module.params.get("state") == "absent": + # Only delete if the aux tag exists + auxtagget = AuxTagGetAPI(module) + result = auxtagget.get() + + if result.http_code == 200: + auxtagdelete = AuxTagDeleteAPI(module) + auxtagdelete.headers["If-Match"] = result.etag + result = auxtagdelete.delete() + + time.sleep(3) + + module.exit_json(**result_as_dict(result)) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aux_tag/tasks/main.yml b/tests/integration/targets/aux_tag/tasks/main.yml new file mode 100644 index 000000000..238480fa2 --- /dev/null +++ b/tests/integration/targets/aux_tag/tasks/main.yml @@ -0,0 +1,35 @@ +--- +- name: "Include Global Variables." + ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', checkmk_var_params) }}" + vars: + checkmk_var_params: + files: + - global.yml + paths: + - /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/ + - /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/ + - tests/integration/files/includes/vars/ + +- name: "Print Identifier." + ansible.builtin.debug: + msg: "{{ ansible_facts.system_vendor }} {{ ansible_facts.product_name }} running {{ ansible_facts.virtualization_type }}" + +- name: "Run preparations." + ansible.builtin.include_tasks: "{{ lookup('ansible.builtin.first_found', checkmk_var_params) }}" + vars: + checkmk_var_params: + files: + - prep.yml + paths: + - /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/ + - /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/ + - tests/integration/files/includes/tasks/ + when: | + (ansible_facts.system_vendor == "Dell Inc." and 'Latitude' in ansible_facts.product_name and ansible_facts.virtualization_type == "container") + or (ansible_facts.system_vendor == "QEMU" and 'Ubuntu' in ansible_facts.product_name and ansible_facts.virtualization_type == "container") + +- name: "Testing." + ansible.builtin.include_tasks: test.yml + loop: "{{ checkmk_var_test_sites }}" + loop_control: + loop_var: outer_item diff --git a/tests/integration/targets/aux_tag/tasks/test.yml b/tests/integration/targets/aux_tag/tasks/test.yml new file mode 100644 index 000000000..8274c0f3a --- /dev/null +++ b/tests/integration/targets/aux_tag/tasks/test.yml @@ -0,0 +1,102 @@ +--- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create auxiliary tag." + checkmk.general.aux_tag: + server_url: "{{ server_url }}" + site: "{{ site }}" + automation_user: "{{ automation_user }}" + automation_secret: "{{ automation_secret }}" + name: "test_aux_tag" + title: "Test Auxiliary Tag" + topic: "Testing" + help: "An auxiliary tag for testing purposes" + state: "present" + register: aux_tag_create + failed_when: aux_tag_create.failed + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag created." + ansible.builtin.assert: + that: + - aux_tag_create.changed is true + - aux_tag_create.http_code == 200 or aux_tag_create.http_code == 204 + fail_msg: "Auxiliary tag was not created successfully!" + success_msg: "Auxiliary tag created successfully." + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create auxiliary tag again (idempotency)." + checkmk.general.aux_tag: + server_url: "{{ server_url }}" + site: "{{ site }}" + automation_user: "{{ automation_user }}" + automation_secret: "{{ automation_secret }}" + name: "test_aux_tag" + title: "Test Auxiliary Tag" + topic: "Testing" + help: "An auxiliary tag for testing purposes" + state: "present" + register: aux_tag_create_again + failed_when: aux_tag_create_again.failed + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify idempotency." + ansible.builtin.assert: + that: + - aux_tag_create_again.changed is false + fail_msg: "Auxiliary tag should not have changed!" + success_msg: "Idempotency verified." + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update auxiliary tag." + checkmk.general.aux_tag: + server_url: "{{ server_url }}" + site: "{{ site }}" + automation_user: "{{ automation_user }}" + automation_secret: "{{ automation_secret }}" + name: "test_aux_tag" + title: "Updated Test Auxiliary Tag" + topic: "Testing" + help: "An updated auxiliary tag for testing purposes" + state: "present" + register: aux_tag_update + failed_when: aux_tag_update.failed + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag updated." + ansible.builtin.assert: + that: + - aux_tag_update.changed is true + - aux_tag_update.http_code == 200 or aux_tag_update.http_code == 204 + fail_msg: "Auxiliary tag was not updated successfully!" + success_msg: "Auxiliary tag updated successfully." + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete auxiliary tag." + checkmk.general.aux_tag: + server_url: "{{ server_url }}" + site: "{{ site }}" + automation_user: "{{ automation_user }}" + automation_secret: "{{ automation_secret }}" + name: "test_aux_tag" + state: "absent" + register: aux_tag_delete + failed_when: aux_tag_delete.failed + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag deleted." + ansible.builtin.assert: + that: + - aux_tag_delete.changed is true + - aux_tag_delete.http_code == 204 or aux_tag_delete.http_code == 200 + fail_msg: "Auxiliary tag was not deleted successfully!" + success_msg: "Auxiliary tag deleted successfully." + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete auxiliary tag again (idempotency)." + checkmk.general.aux_tag: + server_url: "{{ server_url }}" + site: "{{ site }}" + automation_user: "{{ automation_user }}" + automation_secret: "{{ automation_secret }}" + name: "test_aux_tag" + state: "absent" + register: aux_tag_delete_again + failed_when: aux_tag_delete_again.failed + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify deletion idempotency." + ansible.builtin.assert: + that: + - aux_tag_delete_again.changed is false + fail_msg: "Auxiliary tag should not have changed!" + success_msg: "Deletion idempotency verified." From c509261a91f186e5c94f489895acf29a24f2872a Mon Sep 17 00:00:00 2001 From: Nicolas BRAINEZ Date: Fri, 10 Oct 2025 23:22:38 +0200 Subject: [PATCH 2/7] fix: author field --- plugins/modules/aux_tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/aux_tag.py b/plugins/modules/aux_tag.py index 101293c3f..a48a44e5e 100644 --- a/plugins/modules/aux_tag.py +++ b/plugins/modules/aux_tag.py @@ -49,7 +49,7 @@ type: str author: - - brainni (@brainni) + - Nicolas Brainez (@nicoske) """ EXAMPLES = r""" From c3072dea63a22bdcfa7f680e7cc36ab4da81a75d Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 16 Oct 2025 12:56:11 +0200 Subject: [PATCH 3/7] Update changelog. --- changelogs/fragments/aux_tag_module.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelogs/fragments/aux_tag_module.yml b/changelogs/fragments/aux_tag_module.yml index bd8491b3d..9b64105fe 100644 --- a/changelogs/fragments/aux_tag_module.yml +++ b/changelogs/fragments/aux_tag_module.yml @@ -1,2 +1,3 @@ minor_changes: - - aux_tag - New module to manage auxiliary tags in Checkmk. Auxiliary tags can be created, updated, and deleted independently, making it easier to manage tag hierarchies and dependencies. + - aux_tag module - Add new module to manage auxiliary tags in Checkmk. + Auxiliary tags can be created, updated, and deleted independently, making it easier to manage tag hierarchies and dependencies. From 5615c026987d7587e63c0a1801092d624be4f728 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 16 Oct 2025 12:56:30 +0200 Subject: [PATCH 4/7] Add missing variables file. --- .../integration/targets/aux_tag/vars/main.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/integration/targets/aux_tag/vars/main.yml diff --git a/tests/integration/targets/aux_tag/vars/main.yml b/tests/integration/targets/aux_tag/vars/main.yml new file mode 100644 index 000000000..fe390693c --- /dev/null +++ b/tests/integration/targets/aux_tag/vars/main.yml @@ -0,0 +1,22 @@ +--- +checkmk_var_test_sites: + - version: "2.2.0p45" + edition: "cre" + site: "ancient_cre" + port: "5022" + - version: "2.3.0p36" + edition: "cre" + site: "old_cre" + port: "5023" + - version: "2.3.0p36" + edition: "cme" + site: "old_cme" + port: "5323" + - version: "2.4.0p10" + edition: "cre" + site: "stable_cre" + port: "5024" + - version: "2.4.0p10" + edition: "cme" + site: "stable_cme" + port: "5324" From 0c3ff5384d55b43ef196c07a0bee95fd556438a0 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 16 Oct 2025 12:56:44 +0200 Subject: [PATCH 5/7] WIP: Fix integration tests. --- .../targets/aux_tag/tasks/test.yml | 96 ++++++++----------- 1 file changed, 41 insertions(+), 55 deletions(-) diff --git a/tests/integration/targets/aux_tag/tasks/test.yml b/tests/integration/targets/aux_tag/tasks/test.yml index 8274c0f3a..1374815a2 100644 --- a/tests/integration/targets/aux_tag/tasks/test.yml +++ b/tests/integration/targets/aux_tag/tasks/test.yml @@ -1,102 +1,88 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create auxiliary tag." - checkmk.general.aux_tag: - server_url: "{{ server_url }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + aux_tag: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "test_aux_tag" title: "Test Auxiliary Tag" topic: "Testing" help: "An auxiliary tag for testing purposes" state: "present" - register: aux_tag_create - failed_when: aux_tag_create.failed + register: __checkmk_var_aux_tag_create + failed_when: __checkmk_var_aux_tag_create.failed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag created." ansible.builtin.assert: that: - - aux_tag_create.changed is true - - aux_tag_create.http_code == 200 or aux_tag_create.http_code == 204 + - __checkmk_var_aux_tag_create.changed is true + - "'200 - OK: The operation was done successfully' in __checkmk_var_aux_tag_create.msg" fail_msg: "Auxiliary tag was not created successfully!" success_msg: "Auxiliary tag created successfully." - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create auxiliary tag again (idempotency)." - checkmk.general.aux_tag: - server_url: "{{ server_url }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + aux_tag: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "test_aux_tag" title: "Test Auxiliary Tag" topic: "Testing" help: "An auxiliary tag for testing purposes" state: "present" - register: aux_tag_create_again - failed_when: aux_tag_create_again.failed - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify idempotency." - ansible.builtin.assert: - that: - - aux_tag_create_again.changed is false - fail_msg: "Auxiliary tag should not have changed!" - success_msg: "Idempotency verified." + register: __checkmk_var___checkmk_var_aux_tag_create_again + failed_when: __checkmk_var___checkmk_var_aux_tag_create_again.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update auxiliary tag." - checkmk.general.aux_tag: - server_url: "{{ server_url }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + aux_tag: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "test_aux_tag" title: "Updated Test Auxiliary Tag" topic: "Testing" help: "An updated auxiliary tag for testing purposes" state: "present" - register: aux_tag_update - failed_when: aux_tag_update.failed + register: __checkmk_var_aux_tag_update + failed_when: __checkmk_var_aux_tag_update.failed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag updated." ansible.builtin.assert: that: - - aux_tag_update.changed is true - - aux_tag_update.http_code == 200 or aux_tag_update.http_code == 204 + - __checkmk_var_aux_tag_update.changed is true + - __checkmk_var_aux_tag_update.http_code == 200 or __checkmk_var_aux_tag_update.http_code == 204 fail_msg: "Auxiliary tag was not updated successfully!" success_msg: "Auxiliary tag updated successfully." - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete auxiliary tag." - checkmk.general.aux_tag: - server_url: "{{ server_url }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + aux_tag: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "test_aux_tag" state: "absent" - register: aux_tag_delete - failed_when: aux_tag_delete.failed + register: __checkmk_var_aux_tag_delete + failed_when: __checkmk_var_aux_tag_delete.failed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify aux tag deleted." ansible.builtin.assert: that: - - aux_tag_delete.changed is true - - aux_tag_delete.http_code == 204 or aux_tag_delete.http_code == 200 + - __checkmk_var_aux_tag_delete.changed is true + - __checkmk_var_aux_tag_delete.http_code == 204 or __checkmk_var_aux_tag_delete.http_code == 200 fail_msg: "Auxiliary tag was not deleted successfully!" success_msg: "Auxiliary tag deleted successfully." - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete auxiliary tag again (idempotency)." - checkmk.general.aux_tag: - server_url: "{{ server_url }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + aux_tag: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "test_aux_tag" state: "absent" - register: aux_tag_delete_again - failed_when: aux_tag_delete_again.failed - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify deletion idempotency." - ansible.builtin.assert: - that: - - aux_tag_delete_again.changed is false - fail_msg: "Auxiliary tag should not have changed!" - success_msg: "Deletion idempotency verified." + register: __checkmk_var_aux_tag_delete_again + failed_when: __checkmk_var_aux_tag_delete_again.changed From 6109b440a296f5dac8c4a3bdf734aa2706a0746d Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 16 Oct 2025 15:08:35 +0200 Subject: [PATCH 6/7] Add GitHub configuration. --- .github/labels-issues.yml | 3 + .github/labels-prs.yml | 5 + .github/workflows/ans-int-test-aux_tag.yaml | 116 ++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 .github/workflows/ans-int-test-aux_tag.yaml diff --git a/.github/labels-issues.yml b/.github/labels-issues.yml index b1517633a..c9cd926e3 100644 --- a/.github/labels-issues.yml +++ b/.github/labels-issues.yml @@ -17,6 +17,9 @@ inventory: module:activation: - 'Component Name: activation' +module:aux_tag: + - 'Component Name: aux_tag' + module:bakery: - 'Component Name: bakery' diff --git a/.github/labels-prs.yml b/.github/labels-prs.yml index 3dc75767c..47d81d4b3 100644 --- a/.github/labels-prs.yml +++ b/.github/labels-prs.yml @@ -24,6 +24,11 @@ module:activation: - changed-files: - any-glob-to-any-file: 'plugins/modules/activation.py' +module:aux_tag: + - any: + - changed-files: + - any-glob-to-any-file: 'plugins/modules/aux_tag.py' + module:bakery: - any: - changed-files: diff --git a/.github/workflows/ans-int-test-aux_tag.yaml b/.github/workflows/ans-int-test-aux_tag.yaml new file mode 100644 index 000000000..2433a6ff6 --- /dev/null +++ b/.github/workflows/ans-int-test-aux_tag.yaml @@ -0,0 +1,116 @@ +# README: +# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! +# +# Resources: +# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml +# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: aux_tag + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +name: Ansible Integration Tests for Activation Module +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + pull_request: + branches: + - main + - devel + paths: + - 'plugins/modules/aux_tag.py' + push: + paths: + - '.github/workflows/ans-int-test-aux_tag.yaml' + - 'plugins/modules/aux_tag.py' + - 'tests/integration/files/includes/' + - 'tests/integration/targets/aux_tag/' + +jobs: + + integration: + runs-on: ubuntu-24.04 + name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }} + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.17 + - stable-2.18 + - stable-2.19 + - devel + python: + - '3.11' + - '3.12' + exclude: + # Exclude unsupported sets. + - ansible: devel + python: '3.11' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.2.0p45 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.3.0p36 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cme: + image: checkmk/check-mk-managed:2.3.0p36 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "old_cme" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.4.0p10 + ports: + - 5024:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.4.0p10 + ports: + - 5324:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" + + steps: + - name: Check out code + uses: actions/checkout@v5 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: "Install uv and set the python version." + uses: astral-sh/setup-uv@v6 + with: + python-version: ${{ matrix.python }} + enable-cache: true + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/ + + - name: "Setup uv venv." + run: uv venv + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Install ansible-base (${{ matrix.ansible }}) + run: uv pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Run integration test + run: uv run ansible-test integration ${{env.MODULE_NAME}} -v --color --continue-on-error --diff --python ${{ matrix.python }} + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} From 44de1c53befed2d3f90bcee3ef6ead628f2d6733 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 16 Oct 2025 15:09:51 +0200 Subject: [PATCH 7/7] Bugfix GitHub Action. --- .github/workflows/ans-int-test-aux_tag.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ans-int-test-aux_tag.yaml b/.github/workflows/ans-int-test-aux_tag.yaml index 2433a6ff6..b851f307a 100644 --- a/.github/workflows/ans-int-test-aux_tag.yaml +++ b/.github/workflows/ans-int-test-aux_tag.yaml @@ -14,7 +14,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -name: Ansible Integration Tests for Activation Module +name: Ansible Integration Tests for Aux Tag Module on: workflow_dispatch: schedule: