mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Fetch vars for host directly when calculating the delegated user
This fixes the case in which the delegated to host may not be in the specified hosts list, in which cases facts/vars for the host were not available in the injected hostvars. This also fixes the inventory variable fetching function, so that an unknown host raises a proper error as opposed to a NoneType exception. Fixes #8224
This commit is contained in:
parent
2a0d18b092
commit
d19fe8d95d
2 changed files with 14 additions and 1 deletions
|
@ -437,7 +437,10 @@ class Inventory(object):
|
|||
|
||||
def get_variables(self, hostname, update_cached=False, vault_password=None):
|
||||
|
||||
return self.get_host(hostname).get_variables()
|
||||
host = self.get_host(hostname)
|
||||
if not host:
|
||||
raise Exception("host not found: %s" % hostname)
|
||||
return host.get_variables()
|
||||
|
||||
def get_host_variables(self, hostname, update_cached=False, vault_password=None):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue