Fix the way pull localhosts out of inventory for delegate_to
This patch corrects the way we look in the inventory hosts list for implicit localhost entries when localhost aliases are used. Fixes #16568
This commit is contained in:
parent
1f04130c00
commit
83e4a4048b
1 changed files with 11 additions and 8 deletions
|
@ -489,15 +489,18 @@ class VariableManager:
|
||||||
# try looking it up based on the address field, and finally
|
# try looking it up based on the address field, and finally
|
||||||
# fall back to creating a host on the fly to use for the var lookup
|
# fall back to creating a host on the fly to use for the var lookup
|
||||||
if delegated_host is None:
|
if delegated_host is None:
|
||||||
for h in self._inventory.get_hosts(ignore_limits_and_restrictions=True):
|
if delegated_host_name in C.LOCALHOST:
|
||||||
# check if the address matches, or if both the delegated_to host
|
delegated_host = self._inventory.localhost
|
||||||
# and the current host are in the list of localhost aliases
|
|
||||||
if h.address == delegated_host_name or h.name in C.LOCALHOST and delegated_host_name in C.LOCALHOST:
|
|
||||||
delegated_host = h
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
delegated_host = Host(name=delegated_host_name)
|
for h in self._inventory.get_hosts(ignore_limits_and_restrictions=True):
|
||||||
delegated_host.vars.update(new_delegated_host_vars)
|
# check if the address matches, or if both the delegated_to host
|
||||||
|
# and the current host are in the list of localhost aliases
|
||||||
|
if h.address == delegated_host_name:
|
||||||
|
delegated_host = h
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
delegated_host = Host(name=delegated_host_name)
|
||||||
|
delegated_host.vars.update(new_delegated_host_vars)
|
||||||
else:
|
else:
|
||||||
delegated_host = Host(name=delegated_host_name)
|
delegated_host = Host(name=delegated_host_name)
|
||||||
delegated_host.vars.update(new_delegated_host_vars)
|
delegated_host.vars.update(new_delegated_host_vars)
|
||||||
|
|
Loading…
Reference in a new issue