1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add templating support to Icinga2 Inventory (#7996)

* Add templating support to Icinga2 Inventory

* Added CHANGELOG fragment

* Linting after CI failure

* Update changelogs/fragments/7996-Add templating support to Icinga2 Inventory.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Error in variables'name

---------

Co-authored-by: Gianluca Salvo <gianluca.salvo@gruppomol.it>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Gianluca Salvo 2024-02-25 07:37:53 +01:00 committed by GitHub
parent b5c3361be4
commit 638a7fc199
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- icinga2 inventory plugin - add Jinja2 templating support to ``url``, ``user``, and ``password`` paramenters (https://github.com/ansible-collections/community.general/issues/7074, https://github.com/ansible-collections/community.general/pull/7996).

View file

@ -277,12 +277,22 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
self._read_config_data(path) self._read_config_data(path)
# Store the options from the YAML file # Store the options from the YAML file
self.icinga2_url = self.get_option('url').rstrip('/') + '/v1' self.icinga2_url = self.get_option('url')
self.icinga2_user = self.get_option('user') self.icinga2_user = self.get_option('user')
self.icinga2_password = self.get_option('password') self.icinga2_password = self.get_option('password')
self.ssl_verify = self.get_option('validate_certs') self.ssl_verify = self.get_option('validate_certs')
self.host_filter = self.get_option('host_filter') self.host_filter = self.get_option('host_filter')
self.inventory_attr = self.get_option('inventory_attr') self.inventory_attr = self.get_option('inventory_attr')
if self.templar.is_template(self.icinga2_url):
self.icinga2_url = self.templar.template(variable=self.icinga2_url, disable_lookups=False)
if self.templar.is_template(self.icinga2_user):
self.icinga2_user = self.templar.template(variable=self.icinga2_user, disable_lookups=False)
if self.templar.is_template(self.icinga2_password):
self.icinga2_password = self.templar.template(variable=self.icinga2_password, disable_lookups=False)
self.icinga2_url = self.icinga2_url.rstrip('/') + '/v1'
# Not currently enabled # Not currently enabled
# self.cache_key = self.get_cache_key(path) # self.cache_key = self.get_cache_key(path)
# self.use_cache = cache and self.get_option('cache') # self.use_cache = cache and self.get_option('cache')