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

[PR #6286/76dd465e backport][stable-5] icinga2_host: make use of templates and template vars (#6374)

icinga2_host: make use of templates and template vars (#6286)

* icinga2_host: make use of templates, append vars instead of replacing all vars array.

* Initialize `template` variable. Add changelog fragment.

* Update changelogs/fragments/6286-icinga2_host-template-and-template-vars.yml

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

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 76dd465e08)

Co-authored-by: yoannlr <32494673+yoannlr@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2023-04-20 06:34:03 +02:00 committed by GitHub
parent e60daa8509
commit a91255824e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "icinga2_host - fix the data structure sent to Icinga to make use of host templates and template vars (https://github.com/ansible-collections/community.general/pull/6286)."

View file

@ -250,9 +250,9 @@ def main():
state = module.params["state"]
name = module.params["name"]
zone = module.params["zone"]
template = [name]
template = []
if module.params["template"]:
template.append(module.params["template"])
template = [module.params["template"]]
check_command = module.params["check_command"]
ip = module.params["ip"]
display_name = module.params["display_name"]
@ -267,20 +267,18 @@ def main():
module.fail_json(msg="unable to connect to Icinga. Exception message: %s" % (e))
data = {
'templates': template,
'attrs': {
'address': ip,
'display_name': display_name,
'check_command': check_command,
'zone': zone,
'vars': {
'made_by': "ansible",
},
'templates': template,
'vars.made_by': "ansible"
}
}
if variables:
data['attrs']['vars'].update(variables)
for key, value in variables.items():
data['attrs']['vars.' + key] = value
changed = False
if icinga.exists(name):