$variable and jinja variables

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... :slight_smile:

Thanks,
Curtis.

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.

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

Thanks,
Curtis.