mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
caller to preprocess must be None aware (#33653)
also removed unused copy of method fixes #33650
This commit is contained in:
parent
88f1f40aca
commit
0bd9b3019f
2 changed files with 17 additions and 36 deletions
|
@ -195,22 +195,23 @@ class Play(Base, Taggable, Become):
|
||||||
def _load_vars_prompt(self, attr, ds):
|
def _load_vars_prompt(self, attr, ds):
|
||||||
new_ds = preprocess_vars(ds)
|
new_ds = preprocess_vars(ds)
|
||||||
vars_prompts = []
|
vars_prompts = []
|
||||||
for prompt_data in new_ds:
|
if new_ds is not None:
|
||||||
if 'name' not in prompt_data:
|
for prompt_data in new_ds:
|
||||||
display.deprecated("Using the 'short form' for vars_prompt has been deprecated", version="2.7")
|
if 'name' not in prompt_data:
|
||||||
for vname, prompt in prompt_data.items():
|
display.deprecated("Using the 'short form' for vars_prompt has been deprecated", version="2.7")
|
||||||
vars_prompts.append(dict(
|
for vname, prompt in prompt_data.items():
|
||||||
name=vname,
|
vars_prompts.append(dict(
|
||||||
prompt=prompt,
|
name=vname,
|
||||||
default=None,
|
prompt=prompt,
|
||||||
private=None,
|
default=None,
|
||||||
confirm=None,
|
private=None,
|
||||||
encrypt=None,
|
confirm=None,
|
||||||
salt_size=None,
|
encrypt=None,
|
||||||
salt=None,
|
salt_size=None,
|
||||||
))
|
salt=None,
|
||||||
else:
|
))
|
||||||
vars_prompts.append(prompt_data)
|
else:
|
||||||
|
vars_prompts.append(prompt_data)
|
||||||
return vars_prompts
|
return vars_prompts
|
||||||
|
|
||||||
def _compile_roles(self):
|
def _compile_roles(self):
|
||||||
|
|
|
@ -151,26 +151,6 @@ class VariableManager:
|
||||||
raise AnsibleAssertionError("the type of 'value' for options_vars should be a dict, but is a %s" % type(value))
|
raise AnsibleAssertionError("the type of 'value' for options_vars should be a dict, but is a %s" % type(value))
|
||||||
self._options_vars = value.copy()
|
self._options_vars = value.copy()
|
||||||
|
|
||||||
def _preprocess_vars(self, a):
|
|
||||||
'''
|
|
||||||
Ensures that vars contained in the parameter passed in are
|
|
||||||
returned as a list of dictionaries, to ensure for instance
|
|
||||||
that vars loaded from a file conform to an expected state.
|
|
||||||
'''
|
|
||||||
|
|
||||||
if a is None:
|
|
||||||
return None
|
|
||||||
elif not isinstance(a, list):
|
|
||||||
data = [a]
|
|
||||||
else:
|
|
||||||
data = a
|
|
||||||
|
|
||||||
for item in data:
|
|
||||||
if not isinstance(item, MutableMapping):
|
|
||||||
raise AnsibleError("variable files must contain either a dictionary of variables, or a list of dictionaries. Got: %s (%s)" % (a, type(a)))
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def get_vars(self, play=None, host=None, task=None, include_hostvars=True, include_delegate_to=True, use_cache=True):
|
def get_vars(self, play=None, host=None, task=None, include_hostvars=True, include_delegate_to=True, use_cache=True):
|
||||||
'''
|
'''
|
||||||
Returns the variables, with optional "context" given via the parameters
|
Returns the variables, with optional "context" given via the parameters
|
||||||
|
|
Loading…
Reference in a new issue