mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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>
This commit is contained in:
parent
fe798e22a6
commit
76dd465e08
2 changed files with 8 additions and 8 deletions
|
@ -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)."
|
|
@ -256,9 +256,9 @@ def main():
|
||||||
state = module.params["state"]
|
state = module.params["state"]
|
||||||
name = module.params["name"]
|
name = module.params["name"]
|
||||||
zone = module.params["zone"]
|
zone = module.params["zone"]
|
||||||
template = [name]
|
template = []
|
||||||
if module.params["template"]:
|
if module.params["template"]:
|
||||||
template.append(module.params["template"])
|
template = [module.params["template"]]
|
||||||
check_command = module.params["check_command"]
|
check_command = module.params["check_command"]
|
||||||
ip = module.params["ip"]
|
ip = module.params["ip"]
|
||||||
display_name = module.params["display_name"]
|
display_name = module.params["display_name"]
|
||||||
|
@ -273,20 +273,18 @@ def main():
|
||||||
module.fail_json(msg="unable to connect to Icinga. Exception message: %s" % (e))
|
module.fail_json(msg="unable to connect to Icinga. Exception message: %s" % (e))
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
'templates': template,
|
||||||
'attrs': {
|
'attrs': {
|
||||||
'address': ip,
|
'address': ip,
|
||||||
'display_name': display_name,
|
'display_name': display_name,
|
||||||
'check_command': check_command,
|
'check_command': check_command,
|
||||||
'zone': zone,
|
'zone': zone,
|
||||||
'vars': {
|
'vars.made_by': "ansible"
|
||||||
'made_by': "ansible",
|
|
||||||
},
|
|
||||||
'templates': template,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if variables:
|
for key, value in variables.items():
|
||||||
data['attrs']['vars'].update(variables)
|
data['attrs']['vars.' + key] = value
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if icinga.exists(name):
|
if icinga.exists(name):
|
||||||
|
|
Loading…
Reference in a new issue