mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix for bug #264
This commit is contained in:
parent
262b35e7d3
commit
c1fd1348b1
1 changed files with 11 additions and 6 deletions
|
@ -399,19 +399,23 @@ class PlayBook(object):
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
||||||
def _do_conditional_imports(self, vars_files):
|
def _do_conditional_imports(self, vars_files, pattern=None):
|
||||||
''' handle the vars_files section, which can contain variables '''
|
''' handle the vars_files section, which can contain variables '''
|
||||||
|
|
||||||
# FIXME: save parsed variable results in memory to avoid excessive re-reading/parsing
|
# FIXME: save parsed variable results in memory to avoid excessive re-reading/parsing
|
||||||
# FIXME: currently parses imports for hosts not in the pattern, that is not wrong, but it's
|
# FIXME: currently parses imports for hosts not in the pattern, that is not wrong, but it's
|
||||||
# not super optimized yet either, because we wouldn't have hit them, ergo
|
# not super optimized yet either, because we wouldn't have hit them, ergo
|
||||||
# it will raise false errors if there is no defaults variable file without any $vars
|
# it will raise false errors if there is no defaults variable file without any $vars
|
||||||
# in it, which could happen on uncontacted hosts.
|
# in it, which could happen on uncontacted hosts.
|
||||||
|
|
||||||
if type(vars_files) != list:
|
if type(vars_files) != list:
|
||||||
raise errors.AnsibleError("vars_files must be a list")
|
raise errors.AnsibleError("vars_files must be a list")
|
||||||
for host in self.inventory.list_hosts():
|
|
||||||
cache_vars = SETUP_CACHE.get(host,{})
|
host_list = [ h for h in self.inventory.list_hosts(pattern)
|
||||||
|
if not (h in self.stats.failures or h in self.stats.dark) ]
|
||||||
|
|
||||||
|
for host in host_list:
|
||||||
|
cache_vars = SETUP_CACHE.get(host,{})
|
||||||
SETUP_CACHE[host] = cache_vars
|
SETUP_CACHE[host] = cache_vars
|
||||||
for filename in vars_files:
|
for filename in vars_files:
|
||||||
if type(filename) == list:
|
if type(filename) == list:
|
||||||
|
@ -453,12 +457,13 @@ class PlayBook(object):
|
||||||
|
|
||||||
if vars_files is not None:
|
if vars_files is not None:
|
||||||
self.callbacks.on_setup_secondary()
|
self.callbacks.on_setup_secondary()
|
||||||
self._do_conditional_imports(vars_files)
|
self._do_conditional_imports(vars_files, pattern)
|
||||||
else:
|
else:
|
||||||
self.callbacks.on_setup_primary()
|
self.callbacks.on_setup_primary()
|
||||||
|
|
||||||
host_list = [ h for h in self.inventory.list_hosts(pattern)
|
host_list = [ h for h in self.inventory.list_hosts(pattern)
|
||||||
if not (h in self.stats.failures or h in self.stats.dark) ]
|
if not (h in self.stats.failures or h in self.stats.dark) ]
|
||||||
|
|
||||||
self.inventory.restrict_to(host_list)
|
self.inventory.restrict_to(host_list)
|
||||||
|
|
||||||
# push any variables down to the system
|
# push any variables down to the system
|
||||||
|
|
Loading…
Reference in a new issue