variable expansion by template

Hi,

not sure if this i found a bug or this is by intention with the
changes in 0.5 (using latest devel on CentOS6.2):

cat test.yml

Result:
cat /opt/basedir/testfile.txt brings unexpanded variables :frowning:

In the above example, it looks like you set a variable called “base” and are trying to use a variable called “basedir”.

Is this the case?

–Michael

Oh, sorry. I corrected that to $basedir, but still it does not expand
$basedir within the template.
Probably has to do with accessing them in vars_files when declared in
vars before ?

  vars:
    user: root
    group: root
    basedir: /opt/basedir

  vars_files:
    - vars/import.yml

  tasks:
    - action: template src=templates/test_template.j2 dest=$basedir/
testfile.txt

All the variable-reuse stuff is actually loaded up in the template code and shouldn’t care.

I don’t know, you’ll have to debug it and figure it out, I guess.

–Michael

I can see it is expanded correctly:

/etc/ansible/setup

    "config": [
        "Debug=0",
        "LicenseDirectory=/opt/basedir/license",
        "LogDirectory=/opt/basedir/log"
    ],

So passing the array into the jinja-template then doesnt seam to work
correctly:

If i use there {{ config }}
i get out:
['Debug=0', 'LicenseDirectory=$basedir/license', 'LogDirectory=
$basedir/log']