mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #7996/638a7fc1 backport][stable-8] Add templating support to Icinga2 Inventory (#8026)
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>
(cherry picked from commit 638a7fc199
)
Co-authored-by: Gianluca Salvo <Gianlu@users.noreply.github.com>
This commit is contained in:
parent
d9e72cf75e
commit
755ee2b4d0
2 changed files with 13 additions and 1 deletions
|
@ -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).
|
|
@ -277,12 +277,22 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||
self._read_config_data(path)
|
||||
|
||||
# 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_password = self.get_option('password')
|
||||
self.ssl_verify = self.get_option('validate_certs')
|
||||
self.host_filter = self.get_option('host_filter')
|
||||
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
|
||||
# self.cache_key = self.get_cache_key(path)
|
||||
# self.use_cache = cache and self.get_option('cache')
|
||||
|
|
Loading…
Reference in a new issue