foreman: ansible_ssh_host should consider ip, ipv4, ipv6 (#67401)
This commit is contained in:
parent
ffead3b1c0
commit
a5af649a73
1 changed files with 8 additions and 6 deletions
|
@ -263,12 +263,14 @@ class InventoryModule(BaseInventoryPlugin, Cacheable, Constructable):
|
||||||
|
|
||||||
# put ansible_ssh_host as hostvar
|
# put ansible_ssh_host as hostvar
|
||||||
if self.get_option('want_ansible_ssh_host'):
|
if self.get_option('want_ansible_ssh_host'):
|
||||||
if host.get('ip'):
|
for key in ('ip', 'ipv4', 'ipv6'):
|
||||||
|
if host.get(key):
|
||||||
try:
|
try:
|
||||||
self.inventory.set_variable(host_name, 'ansible_ssh_host', host['ip'])
|
self.inventory.set_variable(host_name, 'ansible_ssh_host', host[key])
|
||||||
|
break
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.display.warning("Could not set hostvar ansible_ssh_host to '%s' for the '%s' host, skipping: %s" %
|
self.display.warning("Could not set hostvar ansible_ssh_host to '%s' for the '%s' host, skipping: %s" %
|
||||||
(host['ip'], host_name, to_text(e)))
|
(host[key], host_name, to_text(e)))
|
||||||
|
|
||||||
strict = self.get_option('strict')
|
strict = self.get_option('strict')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue