From 8c9f84f6f8fdc617c558ef8960cadaccd5080dbd Mon Sep 17 00:00:00 2001 From: Alek Storm Date: Thu, 22 Aug 2013 16:43:15 -0700 Subject: [PATCH] Parse --extra-vars as YAML (which includes JSON) --- bin/ansible-playbook | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 78e5ca40bcd..ac25ee30f26 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -62,7 +62,7 @@ def main(args): diff_opts=True ) parser.add_option('-e', '--extra-vars', dest="extra_vars", action="append", - help="set additional variables as key=value or JSON", default=[]) + help="set additional variables as key=value or YAML/JSON", default=[]) parser.add_option('-t', '--tags', dest='tags', default='all', help="only run plays and tasks tagged with these values") parser.add_option('--skip-tags', dest='skip_tags', @@ -101,12 +101,11 @@ def main(args): extra_vars = {} for extra_vars_opt in options.extra_vars: if extra_vars_opt.startswith("@"): - # Argument is a JSON file - with open(extra_vars_opt[1:]) as fd: - extra_vars = utils.combine_vars(extra_vars, utils.json_loads(fd.read())) + # Argument is a YAML file (JSON is a subset of YAML) + extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml_from_file(extra_vars_opt[1:])) elif extra_vars_opt[0] in '[{': - # Arguments as JSON - extra_vars = utils.combine_vars(extra_vars, utils.json_loads(extra_vars_opt)) + # Arguments as YAML + extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml(extra_vars_opt)) else: # Arguments as Key-value extra_vars = utils.combine_vars(extra_vars, utils.parse_kv(extra_vars_opt))