# Role default vars not being read?

**URL:** <https://forum.ansible.com/t/role-default-vars-not-being-read/18185>\
**Category:** Ansible Project\
**Created:** [May 7, 2015, 4:00pm UTC](https://forum.ansible.com/t/role-default-vars-not-being-read/18185 "2015-05-07T16:00:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ticktockhouse](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ticktockhouse/32/8278_2.png) [@ticktockhouse](https://forum.ansible.com/u/ticktockhouse)\
**Post date:** [May 7, 2015, 4:00pm UTC](https://forum.ansible.com/t/role-default-vars-not-being-read/18185/1 "2015-05-07T16:00:26Z")

</div>

I’ve got a role I’m using for testing, but I seem to be stumbling at the first hurdle.

My embryonic playbook looks like this:

`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 7, 2015, 4:06pm UTC](https://forum.ansible.com/t/role-default-vars-not-being-read/18185/2 "2015-05-07T16:06:36Z")

</div>

not sure why you expect those vars to be part of host, your definition  
makes them accessible like this:

{% for host in shinken\_hosts %}  
define host{  
&nbsp;&nbsp;use generic-host  
&nbsp;&nbsp;host\_name {{ host.name }}  
&nbsp;&nbsp;address {{ host.address }}  
&nbsp;&nbsp;alias {{ host.name }}  
&nbsp;&nbsp;check\_command {{ check\_command }}  
&nbsp;&nbsp;\_SSHPORT {{ ssh\_port }}  
&nbsp;&nbsp;contacts {{ contacts }}  
}  
{% endfor %}

which is different from how you define them in the shinken\_hosts

I think you want:  
{% for host in shinken\_hosts %}  
define host{  
&nbsp;&nbsp;use generic-host  
&nbsp;&nbsp;host\_name {{ host.name }}  
&nbsp;&nbsp;address {{ host.address }}  
&nbsp;&nbsp;alias {{ host.name }}  
&nbsp;&nbsp;check\_command {{ host.check\_command|default(check\_command) }}  
&nbsp;&nbsp;\_SSHPORT {{ host.ssh\_port|default(ssh\_port) }}  
&nbsp;&nbsp;contacts {{ host.contacts|default(contacts) }}  
}  
{% endfor %}

---

<div class="post-metadata">

**Author:** ![ticktockhouse](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ticktockhouse/32/8278_2.png) [@ticktockhouse](https://forum.ansible.com/u/ticktockhouse)\
**Post date:** [May 8, 2015, 11:48am UTC](https://forum.ansible.com/t/role-default-vars-not-being-read/18185/3 "2015-05-08T11:48:13Z")

</div>

That’s the puppy!

Thanks for the insight. That template syntax doesn’t seem to be documented anywhere that I can see. Might be useful if it was…

Thanks

Jerry

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 8, 2015, 2:42pm UTC](https://forum.ansible.com/t/role-default-vars-not-being-read/18185/4 "2015-05-08T14:42:24Z")

</div>

The templates are jinja2, you can find the documentations at  
[http://jinja.pocoo.org/docs/dev/](http://jinja.pocoo.org/docs/dev/)
