Conditional include at playbook level would be great

Certain roles/tasks need to be implemented very differently based on the OS.
For example configuring tftpd on Mac vs Linux is done differently:

  • launchctl command on Mac
  • package install/service control on Linux

For this reason I’m looking at using conditional include with a structure such as:

roles/tftpd/tasks:
main.yaml
mac.yaml
linux.yaml

main.yaml (pseudocode):

include mac.yaml when OS variable is mac
include linux.yaml when OS variable is linux

I understand that conditional includes as currently implemented apply the condition
to all tasks in all included playbooks, meaning a lot of “SKIPPED” items showing
up in the messages. I can turn off the skipped msgs display but I’d prefer not
since it’s good info to have for my other playbooks as they run.

I’d love to have a way to do a proper conditional include at the playbook level
rather than at the task level. I’ve seen a number of similar posts and questions
trying to do the same so it seems there’s more interest out there for something
like this.

Thanks,
–Ed

Hi Ed,

You might be interested in the “group_by” module to target dynamic groups, however, which make this super nice.

Take a look at the web documentation and let us know if you need more info.