# template error: AnsibleUndefinedVariable

**URL:** <https://forum.ansible.com/t/template-error-ansibleundefinedvariable/28798>\
**Category:** Ansible Project\
**Created:** [October 16, 2018, 1:36pm UTC](https://forum.ansible.com/t/template-error-ansibleundefinedvariable/28798 "2018-10-16T13:36:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.tremel](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@christian.tremel](https://forum.ansible.com/u/christian.tremel)\
**Post date:** [October 16, 2018, 1:36pm UTC](https://forum.ansible.com/t/template-error-ansibleundefinedvariable/28798/1 "2018-10-16T13:36:59Z")

</div>

hi,

i have a simple template which is driving me nuts, as it throws an bland error. what in blazes does that mean?

the template:

`  
{{ ansible\_managed }}

driftfile /etc/ntp.drift  
tracefile /etc/ntp.trace

{% if inventory\_lparname not in groups[‘DMZ\_HOST’] %}  
server 10.0.0.1  
server some\_host  
{% elif inventory\_lparname in groups[‘DMZ\_HOST’] %}  
server 10.0.0.2  
{% endif %}

`

error:

`  
MSG:

AnsibleUndefinedVariable: Unable to look up a name or access an attribute in template string ({{ ansible\_managed }}

driftfile /etc/ntp.drift  
tracefile /etc/ntp.trace

{% if inventory\_lparname not in groups[‘DMZ\_HOST’] %}  
server 10.0.0.1  
server some\_host  
{% elif inventory\_lparname in groups[‘DMZ\_HOST’] %}  
server 10.0.0.2  
{% endif %}  
).  
Make sure your variable name does not contain invalid characters like ‘-’: argument of type ‘StrictUndefined’ is not iterable

`
