Conditional include

I want to mass include .yml files under the tasks folder when a condition is met, something like

  • include:
  • foo.yml
  • bar.yml
    when: ansible_os_family == “Debian”

Is it possible currently?

no, includes are not conditional.

what that does is add the condition to each task in the includes.

So it’s basically the same thing in the end :slight_smile:

Note that this behavior is improved in 1.3, where if you have any conditions they are inserted before any conditions in the task.

I also highly recommend the group_by module for conditional application of roles.