On Friday, December 19, 2014 at 7:50:09 AM UTC-8, Dario Bertini wrote:
>
> I was thinking of simply using
>
> ansible -m debug -a "msg={{the_jinja_expression_I_want_to_test}}"
>
> but I realized that the output is not quite what I'd expect:
>
> ansible -m debug -a "msg={{hostvars[inventory_hostname]}}"
>
> ansible -m debug -a "msg={{hostvars}}"
>

I agree it's not totally obvious.

The answer at http://serverfault.com/a/695798 helped me figure out that it 
needed to be quoted.

quote your test expressions and you get the output you expected:


# ansible --version
ansible 1.9.6
  configured module search path = None

# ansible -m debug -a msg="'{{hostvars[inventory_hostname]}}'"
localhost | success >> {
    "msg": "{'inventory_hostname': '127.0.0.1', 'group_names': 
['ungrouped'], 'inventory_hostname_short': '127'}"
}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e2a7b30c-bf79-4ace-b9b8-2419593290a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to