Hi Alexey, It is possible to use variables in include statements, however there is one limitation - the variables must be known at the time the playbook YAML is parsed, and therefore cannot be based on "inventory" variables (facts, group_vars or host_vars) or parameterized role variables (which is why your test case is failing).
What you can do instead is a conditional include: - include: one_sub_task.yml when: subtask == 'one_sub_task' - include: another_sub_task.yml when: subtask == 'another_sub_task' Hope that helps! On Wed, Oct 1, 2014 at 4:26 PM, Alexey Malov <[email protected]> wrote: > Hello all, > Hope you are doing well. > > Could you please tell me if it's possible to use variables in the include > statement? > I'm trying to do next thing: > 1. Have some role, for example 'superrole'. > 2. And have some tasks inside it. > 3. Use main task to include subtasks based on variables like > # main.yml > --- > - include {{ subtask }}.tml > 3. To po next in the playbooks: > - { role: superrole, subtask: one_sub_task } > - { role: superrole, subtask: another_sub_task } > > Thank you very much, > Alex. > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/ca6eddd4-884c-42eb-acb8-917560e97887%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/ca6eddd4-884c-42eb-acb8-917560e97887%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAMFyvFidYA-%2BcwCd0HHwoF2Vi9UCGrGD3WboWdcfwC14HHrbVg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
