Skip to content
Open
64 changes: 64 additions & 0 deletions .github/workflows/ans-int-test-inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Inventory Plugin Integration

permissions:
contents: read

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
pull_request:
branches:
- main
- devel
types:
- opened
paths:
- 'plugins/inventory/checkmk.py'
push:
paths:
- '.github/workflows/ans-int-test-inventory.yaml'
- 'plugins/inventory/checkmk.py'
- 'plugins/module_utils/**'
- 'tests/integration/files/includes/**'
- 'tests/integration/targets/inventory/**'

jobs:

integration:
name: "${{ matrix.checkmk_version }}.${{ matrix.checkmk_edition }}"
uses: ./.github/workflows/_template-ans-int-test.yaml
with:
module: inventory
checkmk_version: ${{ matrix.checkmk_version }}
checkmk_edition: ${{ matrix.checkmk_edition }}
strategy:
fail-fast: false
matrix:
checkmk_version:
- 2.3.0p48
- 2.4.0p31
- 2.5.0p6
checkmk_edition:
- raw
- managed
- community
- ultimatemt
exclude:
- checkmk_version: 2.3.0p48
checkmk_edition: community
- checkmk_version: 2.3.0p48
checkmk_edition: ultimatemt
- checkmk_version: 2.4.0p31
checkmk_edition: community
- checkmk_version: 2.4.0p31
checkmk_edition: ultimatemt
- checkmk_version: 2.5.0p6
checkmk_edition: raw
- checkmk_version: 2.5.0p6
checkmk_edition: managed
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ You can find playbooks, demonstrating the content of this collection in the fold

Name | Description | Tests
--- | --- | ---
[checkmk.general.checkmk](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/inventory/checkmk.py)|Dynamic Inventory Source for Checkmk. | [![Ansible Unit Test for Inventory Module.](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml)
[checkmk.general.checkmk](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/inventory/checkmk.py)|Dynamic Inventory Source for Checkmk. | [![Ansible Unit Test for Inventory Module.](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml) [![Inventory Plugin Integration](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-inventory.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-inventory.yaml)

### :mag: Lookup plugins
Click on the lookup plugin name below, to get detailed documentation about it.
Expand Down
10 changes: 10 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ api_user: "myuser"
api_secret: "mysecret"
# Group the hosts based on the following elements
groupsources: ["hosttags", "sites"]
want_ipv4: false
folder: "/"
recursive: true
lowercase_hosts: true
domain_map:
tag_criticality_prod: ".example.com"
tag_criticality_test: ".test.example.com"
exclude_tags:
- tag_criticality_test

```

You can then run your playbook by pointing to this inventory file with the `-i` flag:
Expand Down
5 changes: 5 additions & 0 deletions changelogs/fragments/inventory_host_filtering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
minor_changes:
- Checkmk Inventory plugin - Add ``folder`` and ``recursive`` options to restrict the inventory to a Checkmk folder and optionally its subfolders.
- Checkmk Inventory plugin - Add ``exclude_tags`` option to exclude hosts with certain tags from the inventory.
- Checkmk Inventory plugin - Add ``lowercase_hosts`` option to convert hostnames to lowercase.
- Checkmk Inventory plugin - Add ``domain_map`` option to append a domain suffix to hostnames based on host tags.
7 changes: 7 additions & 0 deletions playbooks/inventory/checkmk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ api_secret: "mysecret"
validate_certs: false
groupsources: ["hosttags", "sites"]
want_ipv4: false
folder: "/"
recursive: true
lowercase_hosts: true
domain_map:
tag_criticality_prod: ".example.com"
exclude_tags:
- tag_criticality_test
Loading
Loading