community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Adds group_by_hostgroups parameter to Icinga2 inventory

Open Gianlu opened this issue 6 months ago • 10 comments

SUMMARY

This PR adds an optional parameter to Icinga2 inventory group_by_hostgroups (boolean). If true, Icinga2 hostgroups are used as Ansible groups; if false the step is ignored. For backward compatibility, the default is true.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

icinga2.py inventory

ADDITIONAL INFORMATION

In my use case, I want to use Icinga2 as inventory source but my hostgroups' naming convention isn't suitable to become an ansible group strategy (spaces, capital letters and invalid characters) so I prefer to disable the builtin grouping by hostgroups and use the capabilities of constructed inventory (groups and keyed_groups).

# my.icinga2.yml
plugin: community.general.icinga2
url: http://localhost:5665
user: ansible
password: secure
host_filter: \"linux-servers\" in host.groups
validate_certs: false  # only do this when connecting to localhost!
group_by_hostgroups: false

Gianlu avatar Feb 21 '24 07:02 Gianlu