When debugging ansible I like to do a json dump of EVERYTHING. But I'm not 
seeing my extra-vars in my dump. Here's the jinja template to dump all 
ansible's internal variables. What can I add to see the extra-vars?

{
"hostvars": {
{% for key in groups["all"] %}
  "{{key}}": {{ hostvars[key] |to_nice_json }}
,
{% endfor %}

  "localhost":   {{hostvars['localhost'] | to_nice_json}}
},
"vars":        {{ vars | to_nice_json }}
,
"environment": {{ environment | to_nice_json }}
,
"group_names": {{ group_names | to_nice_json }}
,
"groups":      {{ groups | to_nice_json }}
}

Example Playbook:

- hosts: localhost
  tasks:
    - shell: echo hello {{ xvar }}
      register: hello
- include: dump.pb   # this is my JSON dump code

If I run this without defining xvar I get an error. The following command 
succeeds:

ansible-playbook -i hosts_cpci1 tmp.pb --extra-vars "xvar=world"

The JSON dump shows that xvar=world got through but xvar doesn't show up in 
either the vars or localhost listing. Abridged JSON output below.

 "hostvars": { "localhost": {  "hello": {
        "cmd": "echo hello world", }        }    }
"vars": {
    "always_run": false,
    "ansible_version": { "full": "1.9.2" },
    "delegate_to": "127.0.0.1",
    "playbook_dir": "/home/ansible/test",
}

-- 
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/a704b5b5-d35b-4c7a-81e5-6f4edcec828b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to