Looking for a way execute tasks in included file based on condition

Hello Guys,

This has been probably solved before so apologies if this is a repeat. I was confused about tasks in a include file being run even though the condition for the include itself is not true.

so in my main.yml I have an include system like a switch kind of logique: say

  • include: this.yml

when: include_this_enable|default(false)

  • include: that.yml

when: include_that_enable|default(false)

To my surprise I needed to also add the when conditions to this.yml and that.yml for it to work before everything would run otherwise as shown in here http://pastie.org/10392488

when this.yml has a lot of tasks this become difficult to do. How to strictly run tasks in this.yml only base on a condition?

Thanks in advance

Best Regads,

The when conditions will not avoid issues with a undefined or
incorrectly typed var in a with_ , as they get executed for each item
inside the with_.

Hello Brian,

Thanks for the email. So there is no way to skip the inclusion of the file in the first place?

Best Regards,