# $variable and jinja variables

**URL:** <https://forum.ansible.com/t/variable-and-jinja-variables/11785>\
**Category:** Ansible Project\
**Created:** [August 10, 2012, 11:23pm UTC](https://forum.ansible.com/t/variable-and-jinja-variables/11785 "2012-08-10T23:23:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [August 10, 2012, 11:23pm UTC](https://forum.ansible.com/t/variable-and-jinja-variables/11785/1 "2012-08-10T23:23:01Z")

</div>

Hi All,

I have a problem I can't figure out...I have a template file which is  
a php config file, hence $variable.

# grep pemkey templates/secrets.j2  
$pemkey = '{{ pemkey }}'; # random passphrase - same as given to  
genkeys.sh - should be long

And a ansible variable (don't worry about the password, it's temp):

# grep pemkey vars/main.yml  
pemkey: 'Ohbuwie9aeQu'

and then when the file is generated from the template I get:

# grep Ohbuwie9aeQu secrets.php  
Ohbuwie9aeQu = 'Ohbuwie9aeQu'; # random passphrase - same as given to  
genkeys.sh - should be long

when I'm expecting:

$pemkey = 'Ohbuwie9aeQu'

This is the ansible version I'm running:

# rpm -qa | grep ansible  
ansible-0.7-0.git201208091946.el6.noarch

Any thoughts? I saw this once before then upgraded ansible and it went  
away, but I have seen the problem today on ansible 0.5.1, 0.6 and the  
above version.

I wouldn't think that jinja would replace {{ variable }} and $variable...?

Hopefully it's something silly... 🙂

Thanks,  
Curtis.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 10, 2012, 11:43pm UTC](https://forum.ansible.com/t/variable-and-jinja-variables/11785/2 "2012-08-10T23:43:50Z")

</div>

> Hi All,
> 
> I have a problem I can't figure out...I have a template file which is  
> a php config file, hence $variable.

ok

> # grep pemkey templates/secrets.j2  
> $pemkey = '{{ pemkey }}'; # random passphrase - same as given to  
> genkeys.sh - should be long
> 
> And a ansible variable (don't worry about the password, it's temp):
> 
> # grep pemkey vars/main.yml  
> pemkey: 'Ohbuwie9aeQu'
> 
> and then when the file is generated from the template I get:
> 
> # grep Ohbuwie9aeQu secrets.php  
> Ohbuwie9aeQu = 'Ohbuwie9aeQu'; # random passphrase - same as given to  
> genkeys.sh - should be long
> 
> when I'm expecting:
> 
> $pemkey = 'Ohbuwie9aeQu'
> 
> This is the ansible version I'm running:
> 
> # rpm -qa | grep ansible  
> ansible-0.7-0.git201208091946.el6.noarch
> 
> Any thoughts? I saw this once before then upgraded ansible and it went  
> away, but I have seen the problem today on ansible 0.5.1, 0.6 and the  
> above version.

HA, yeah.

Basically what is happening is the Non-Jinja2 template substitution is  
happening INSIDE the template, so the workaround for now is to just  
name your variable  
pemkeydata or something, so it doesn't successfully replace $pemkey.

While we COULD disable non-Jinja2 basic templating, I do not think we  
want to, because many people might be using it -- and templating PHP  
or Perl is less common  
than most other things.

Honestly, I like people not having to know/use Jinja2 unless they want  
to. $foo is cleaner for a lot of simple stuff.

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [August 11, 2012, 3:41am UTC](https://forum.ansible.com/t/variable-and-jinja-variables/11785/3 "2012-08-11T03:41:33Z")

</div>

Ok, I didn't know there was basic templating. Will change variable names.

Thanks,  
Curtis.
