|
|
@ -71,7 +71,7 @@ def preprocess_vars(a):
|
|
|
|
if a is None:
|
|
|
|
if a is None:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
elif not isinstance(a, list):
|
|
|
|
elif not isinstance(a, list):
|
|
|
|
data = [ a ]
|
|
|
|
data = [a]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
data = a
|
|
|
|
data = a
|
|
|
|
|
|
|
|
|
|
|
@ -81,6 +81,7 @@ def preprocess_vars(a):
|
|
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def strip_internal_keys(dirty):
|
|
|
|
def strip_internal_keys(dirty):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
All keys stating with _ansible_ are internal, so create a copy of the 'dirty' dict
|
|
|
|
All keys stating with _ansible_ are internal, so create a copy of the 'dirty' dict
|
|
|
@ -119,15 +120,15 @@ class VariableManager:
|
|
|
|
|
|
|
|
|
|
|
|
def __getstate__(self):
|
|
|
|
def __getstate__(self):
|
|
|
|
data = dict(
|
|
|
|
data = dict(
|
|
|
|
fact_cache = self._fact_cache,
|
|
|
|
fact_cache=self._fact_cache,
|
|
|
|
np_fact_cache = self._nonpersistent_fact_cache,
|
|
|
|
np_fact_cache=self._nonpersistent_fact_cache,
|
|
|
|
vars_cache = self._vars_cache,
|
|
|
|
vars_cache=self._vars_cache,
|
|
|
|
extra_vars = self._extra_vars,
|
|
|
|
extra_vars=self._extra_vars,
|
|
|
|
host_vars_files = self._host_vars_files,
|
|
|
|
host_vars_files=self._host_vars_files,
|
|
|
|
group_vars_files = self._group_vars_files,
|
|
|
|
group_vars_files=self._group_vars_files,
|
|
|
|
omit_token = self._omit_token,
|
|
|
|
omit_token=self._omit_token,
|
|
|
|
options_vars = self._options_vars,
|
|
|
|
options_vars=self._options_vars,
|
|
|
|
#inventory = self._inventory,
|
|
|
|
# inventory=self._inventory,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
@ -192,7 +193,7 @@ class VariableManager:
|
|
|
|
if a is None:
|
|
|
|
if a is None:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
elif not isinstance(a, list):
|
|
|
|
elif not isinstance(a, list):
|
|
|
|
data = [ a ]
|
|
|
|
data = [a]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
data = a
|
|
|
|
data = a
|
|
|
|
|
|
|
|
|
|
|
@ -307,7 +308,7 @@ class VariableManager:
|
|
|
|
# the with_first_found mechanism.
|
|
|
|
# the with_first_found mechanism.
|
|
|
|
vars_file_list = vars_file_item
|
|
|
|
vars_file_list = vars_file_item
|
|
|
|
if not isinstance(vars_file_list, list):
|
|
|
|
if not isinstance(vars_file_list, list):
|
|
|
|
vars_file_list = [ vars_file_list ]
|
|
|
|
vars_file_list = [vars_file_list]
|
|
|
|
|
|
|
|
|
|
|
|
# now we iterate through the (potential) files, and break out
|
|
|
|
# now we iterate through the (potential) files, and break out
|
|
|
|
# as soon as we read one from the list. If none are found, we
|
|
|
|
# as soon as we read one from the list. If none are found, we
|
|
|
@ -389,7 +390,7 @@ class VariableManager:
|
|
|
|
if task and task.delegate_to is not None and include_delegate_to:
|
|
|
|
if task and task.delegate_to is not None and include_delegate_to:
|
|
|
|
all_vars['ansible_delegated_vars'] = self._get_delegated_vars(loader, play, task, all_vars)
|
|
|
|
all_vars['ansible_delegated_vars'] = self._get_delegated_vars(loader, play, task, all_vars)
|
|
|
|
|
|
|
|
|
|
|
|
#VARIABLE_CACHE[cache_entry] = all_vars
|
|
|
|
# VARIABLE_CACHE[cache_entry] = all_vars
|
|
|
|
if task or play:
|
|
|
|
if task or play:
|
|
|
|
all_vars['vars'] = all_vars.copy()
|
|
|
|
all_vars['vars'] = all_vars.copy()
|
|
|
|
|
|
|
|
|
|
|
@ -439,7 +440,7 @@ class VariableManager:
|
|
|
|
variables['ansible_play_hosts'] = [x for x in variables['ansible_play_hosts_all'] if x not in play._removed_hosts]
|
|
|
|
variables['ansible_play_hosts'] = [x for x in variables['ansible_play_hosts_all'] if x not in play._removed_hosts]
|
|
|
|
variables['ansible_play_batch'] = [x.name for x in self._inventory.get_hosts() if x.name not in play._removed_hosts]
|
|
|
|
variables['ansible_play_batch'] = [x.name for x in self._inventory.get_hosts() if x.name not in play._removed_hosts]
|
|
|
|
|
|
|
|
|
|
|
|
#DEPRECATED: play_hosts should be deprecated in favor of ansible_play_batch,
|
|
|
|
# DEPRECATED: play_hosts should be deprecated in favor of ansible_play_batch,
|
|
|
|
# however this would take work in the templating engine, so for now we'll add both
|
|
|
|
# however this would take work in the templating engine, so for now we'll add both
|
|
|
|
variables['play_hosts'] = variables['ansible_play_batch']
|
|
|
|
variables['play_hosts'] = variables['ansible_play_batch']
|
|
|
|
|
|
|
|
|
|
|
@ -628,7 +629,6 @@ class VariableManager:
|
|
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_group_vars_file(self, path, loader):
|
|
|
|
def add_group_vars_file(self, path, loader):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Loads and caches a host_vars file in the _host_vars_files dict,
|
|
|
|
Loads and caches a host_vars file in the _host_vars_files dict,
|
|
|
|