# Templates

**URL:** <https://forum.ansible.com/t/templates/12106>\
**Category:** Ansible Project\
**Created:** [November 27, 2012, 4:55pm UTC](https://forum.ansible.com/t/templates/12106 "2012-11-27T16:55:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce1](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Bruce1](https://forum.ansible.com/u/Bruce1)\
**Post date:** [November 27, 2012, 4:55pm UTC](https://forum.ansible.com/t/templates/12106/1 "2012-11-27T16:55:13Z")

</div>

I’m just getting started with playing with templates, having never used jinja2 before. I’ve written a very simple template:

stacktype={{ stacktype }}  
{% if stacktype == “stg” %}

test  
{% endif %}

end

My hosts script defines the stacktype variable:

“stacktype” : [  
“stg”  
],

When I run my playbook and look at the resulting file I get the following:

stacktype=[u’stg’]

end

Why is the variable being reported as [u’stg’] instead of just “stg”? What’s the correct way to use this in a jinja2 conditional?

-Bruce

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [November 27, 2012, 5:10pm UTC](https://forum.ansible.com/t/templates/12106/2 "2012-11-27T17:10:53Z")

</div>

‘u’ there is for ‘unicode string’, its a python encoding semantic, also if you are comparing a string to a dictionary.

define it as  
“stacktype”: “stg”

and it should work as intended

---

<div class="post-metadata">

**Author:** ![Bruce1](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Bruce1](https://forum.ansible.com/u/Bruce1)\
**Post date:** [November 27, 2012, 5:18pm UTC](https://forum.ansible.com/t/templates/12106/3 "2012-11-27T17:18:00Z")

</div>

Thanks. Working like a charm!

-Bruce
