Include with tasks

Inclusion works fine with vars_files.
But not with tasks when a variable is used within a filename ?

  var:
    product: abc

  vars_files:
     - vars/${product}.yml

  tasks:
   - include: tasks/${product}.yml

When the playbook is run you get - though the file is there:
ERROR: file not found: tasks/${product}.yml

Inclusion works fine with vars_files.
But not with tasks when a variable is used within a filename ?

var:
product: abc

It’s called “vars”.

This is the problem. I will make me a ticket to make it yell when invalid keywords are found in the play or task.

:slight_smile:

Sorry, its a typo in this post...
in real it is vars: of course.

So in changing it to “vars” is the problem is still there?

Yes, problem still there.
In vars_files the $product is resolved,
in tasks - include: tasks/${product}.yml it is not..

(devel checkout from today)

Oh, task includes, that narrows it down nicely, I was thinking of vars_files.

I suspect you are the first to try this, it's just a missing template
call around the path. Pretty simple.

Please make sure there is a ticket in github.

--Michael