Variables not getting expanded in the template module in ansible 0.4

Given this playbook:

  • hosts: machines
    tasks:
  • include: atask.yaml foo=“bar”

and the atask.yaml file:

More exactly, in the previous version it was actually expanding the parameter and looking to template a source file “bar”, but with version 0.4 i get:

PLAY [machines] ****************************

SETUP PHASE ****************************

ok: [machine1]

TASK: [test task] *********

ok: [machine1] => command echo “bar” #USE_SHELL

TASK: [test task 2] *********

fatal: [None] => {‘msg’: “[Errno 2] No such file or directory: u’./$foo’”, ‘failed’: True}
fatal: [None] => {‘msg’: “[Errno 2] No such file or directory: u’./$foo’”, ‘failed’: True}

For the shell task it seems to expand it ok, but for template is not working anymore and it actually looks for a file called “$foo”.
Is this the expected behaviour?

yeah, definitely not expected.

There’s at least one other issue with parameterized includes in 0.4 though … that the templates can’t see those variables either, so it stands to reason that parameterized includes are just busted in 0.4.

If someone wants to patch them to work I can do a point release.

(0.5 devel branch shouldn’t have this problem as the parameterized include stuff, and the way things are substituted out is basically rewritten – so we shouldn’t have to worry about porting that fix forward)

–Michael

I know 0.4 has just been released, but how far off do you estimate 0.5 to be? Is it worth trying to fix 0.4?

I think so, yes – though I’m strongly trying to get other people involved in the development effort, so I’m just going to devote my particular efforts to 0.5.

Generally we’ve been releasing every 30 days or so, 0.5 is a bit heavy, so I could see it being a bit longer than a month.

–Michael