summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Bonelli <fbonelli@gmail.com>2013-05-28 09:46:50 +0200
committerFabio Bonelli <fbonelli@gmail.com>2013-05-28 09:46:50 +0200
commit6bef150695e4aea142fbb0aa3024e5b9e645621b (patch)
tree4f58c89305c7063f68276bc018ec33262600ee0f
parent5ec35fa38850e6fc2d8b6b70141b4233b5e3036a (diff)
downloadansible-6bef150695e4aea142fbb0aa3024e5b9e645621b.tar.gz
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.
-rwxr-xr-xbin/ansible-playbook5
-rw-r--r--docs/man/man1/ansible-playbook.1.asciidoc.in3
2 files changed, 6 insertions, 2 deletions
diff --git a/bin/ansible-playbook b/bin/ansible-playbook
index 79c883fced..ea99342f39 100755
--- a/bin/ansible-playbook
+++ b/bin/ansible-playbook
@@ -98,7 +98,10 @@ def main(args):
if options.sudo_user or options.ask_sudo_pass:
options.sudo = True
options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER
- extra_vars = utils.parse_kv(options.extra_vars)
+ if options.extra_vars[0] in '[{':
+ extra_vars = utils.json_loads(options.extra_vars)
+ else:
+ extra_vars = utils.parse_kv(options.extra_vars)
only_tags = options.tags.split(",")
for playbook in args:
diff --git a/docs/man/man1/ansible-playbook.1.asciidoc.in b/docs/man/man1/ansible-playbook.1.asciidoc.in
index ecb32e81be..6eb79808db 100644
--- a/docs/man/man1/ansible-playbook.1.asciidoc.in
+++ b/docs/man/man1/ansible-playbook.1.asciidoc.in
@@ -51,7 +51,8 @@ The 'DIRECTORY' to load modules from. The default is '/usr/share/ansible'.
*-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'::