So I am running ansible 2.3.0.0. What I want to do is to have my
handlers/main.yml file to include another file (where some handlers
are defined) whose name depends on a variable defined somewhere else.
i.e.
- include: stuff"{{ myvariable }}".yml
where myvariable is defined in the file group_vars/all. I also have
ERROR! Error when evaluating variable in include name: stuff"{{
myvariable }}".yml.
When using static includes, ensure that any variables used in their
names are defined in
vars/vars_files or extra-vars passed in from the command line. Static
includes cannot use
variables from inventory sources like group or host vars.
Where does it want me to define myvariable then? Somewhere in, say,
roles/role_in_question/vars/main.yml?
Filename variables in static inclusion could only be defined in 3 places , any one is ok.
extra vars from command line
in vars section of the playbook, not the vars or defaults directory of the role
in vars_file section of the playbook
I don’t see non used from your description.
I have published a repo in github to show the usage of all the ways to define the filename variables. Basically, you should pay attention to the 2 commits