Templates

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

‘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

Thanks. Working like a charm!

-Bruce