Make extra_vars into unicode string type early

Fixes v2 for #10106
pull/8091/merge
Toshio Kuratomi 10 years ago
parent 6d788629a2
commit 1ed1af6cb4

@ -13,6 +13,7 @@ from ansible.parsing.splitter import parse_kv
from ansible.playbook import Playbook from ansible.playbook import Playbook
from ansible.playbook.task import Task from ansible.playbook.task import Task
from ansible.utils.cli import base_parser from ansible.utils.cli import base_parser
from ansible.utils.unicode import to_unicode
from ansible.utils.vars import combine_vars from ansible.utils.vars import combine_vars
from ansible.vars import VariableManager from ansible.vars import VariableManager
@ -105,10 +106,11 @@ def main(args):
extra_vars = {} extra_vars = {}
for extra_vars_opt in options.extra_vars: for extra_vars_opt in options.extra_vars:
if extra_vars_opt.startswith("@"): extra_vars_opt = to_unicode(extra_vars_opt)
if extra_vars_opt.startswith(u"@"):
# Argument is a YAML file (JSON is a subset of YAML) # Argument is a YAML file (JSON is a subset of YAML)
data = loader.load_from_file(extra_vars_opt[1:]) data = loader.load_from_file(extra_vars_opt[1:])
elif extra_vars_opt and extra_vars_opt[0] in '[{': elif extra_vars_opt and extra_vars_opt[0] in u'[{':
# Arguments as YAML # Arguments as YAML
data = loader.load(extra_vars_opt) data = loader.load(extra_vars_opt)
else: else:

Loading…
Cancel
Save