Support JSON in --extra-vars.

If --extra-vars starts with either a '{' or a '[', it will be assumed
we are dealing with JSON and parse the data as such.
pull/3040/head
Fabio Bonelli 12 years ago
parent 5ec35fa388
commit 6bef150695

@ -98,6 +98,9 @@ def main(args):
if options.sudo_user or options.ask_sudo_pass: if options.sudo_user or options.ask_sudo_pass:
options.sudo = True options.sudo = True
options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER
if options.extra_vars[0] in '[{':
extra_vars = utils.json_loads(options.extra_vars)
else:
extra_vars = utils.parse_kv(options.extra_vars) extra_vars = utils.parse_kv(options.extra_vars)
only_tags = options.tags.split(",") only_tags = options.tags.split(",")

@ -51,7 +51,8 @@ The 'DIRECTORY' to load modules from. The default is '/usr/share/ansible'.
*-e* 'VARS', *--extra-vars=*'VARS':: *-e* 'VARS', *--extra-vars=*'VARS'::
Extra variables to inject into a playbook, in key=value key=value format. Extra variables to inject into a playbook, in key=value key=value format or
as JSON (objects and arrays).
*-f* 'NUM', *--forks=*'NUM':: *-f* 'NUM', *--forks=*'NUM'::

Loading…
Cancel
Save