|
|
|
@ -121,23 +121,24 @@ def merge_hash(a, b):
|
|
|
|
|
|
|
|
|
|
def load_extra_vars(loader, options):
|
|
|
|
|
extra_vars = {}
|
|
|
|
|
for extra_vars_opt in options.extra_vars:
|
|
|
|
|
data = None
|
|
|
|
|
extra_vars_opt = to_text(extra_vars_opt, errors='surrogate_or_strict')
|
|
|
|
|
if extra_vars_opt.startswith(u"@"):
|
|
|
|
|
# Argument is a YAML file (JSON is a subset of YAML)
|
|
|
|
|
data = loader.load_from_file(extra_vars_opt[1:])
|
|
|
|
|
elif extra_vars_opt and extra_vars_opt[0] in u'[{':
|
|
|
|
|
# Arguments as YAML
|
|
|
|
|
data = loader.load(extra_vars_opt)
|
|
|
|
|
else:
|
|
|
|
|
# Arguments as Key-value
|
|
|
|
|
data = parse_kv(extra_vars_opt)
|
|
|
|
|
|
|
|
|
|
if isinstance(data, MutableMapping):
|
|
|
|
|
extra_vars = combine_vars(extra_vars, data)
|
|
|
|
|
else:
|
|
|
|
|
raise AnsibleOptionsError("Invalid extra vars data supplied. '%s' could not be made into a dictionary" % extra_vars_opt)
|
|
|
|
|
if hasattr(options, 'extra_vars'):
|
|
|
|
|
for extra_vars_opt in options.extra_vars:
|
|
|
|
|
data = None
|
|
|
|
|
extra_vars_opt = to_text(extra_vars_opt, errors='surrogate_or_strict')
|
|
|
|
|
if extra_vars_opt.startswith(u"@"):
|
|
|
|
|
# Argument is a YAML file (JSON is a subset of YAML)
|
|
|
|
|
data = loader.load_from_file(extra_vars_opt[1:])
|
|
|
|
|
elif extra_vars_opt and extra_vars_opt[0] in u'[{':
|
|
|
|
|
# Arguments as YAML
|
|
|
|
|
data = loader.load(extra_vars_opt)
|
|
|
|
|
else:
|
|
|
|
|
# Arguments as Key-value
|
|
|
|
|
data = parse_kv(extra_vars_opt)
|
|
|
|
|
|
|
|
|
|
if isinstance(data, MutableMapping):
|
|
|
|
|
extra_vars = combine_vars(extra_vars, data)
|
|
|
|
|
else:
|
|
|
|
|
raise AnsibleOptionsError("Invalid extra vars data supplied. '%s' could not be made into a dictionary" % extra_vars_opt)
|
|
|
|
|
|
|
|
|
|
return extra_vars
|
|
|
|
|
|
|
|
|
@ -146,7 +147,8 @@ def load_options_vars(options, version):
|
|
|
|
|
options_vars = {}
|
|
|
|
|
# For now only return check mode, but we can easily return more
|
|
|
|
|
# options if we need variables for them
|
|
|
|
|
options_vars['ansible_check_mode'] = options.check
|
|
|
|
|
if hasattr(options, 'check'):
|
|
|
|
|
options_vars['ansible_check_mode'] = options.check
|
|
|
|
|
options_vars['ansible_version'] = version
|
|
|
|
|
return options_vars
|
|
|
|
|
|
|
|
|
|