# Conditional include at playbook level would be great

**URL:** <https://forum.ansible.com/t/conditional-include-at-playbook-level-would-be-great/16920>\
**Category:** Ansible Developer\
**Created:** [November 30, 2014, 4:26pm UTC](https://forum.ansible.com/t/conditional-include-at-playbook-level-would-be-great/16920 "2014-11-30T16:26:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![edrozenberg](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@edrozenberg](https://forum.ansible.com/u/edrozenberg)\
**Post date:** [November 30, 2014, 4:26pm UTC](https://forum.ansible.com/t/conditional-include-at-playbook-level-would-be-great/16920/1 "2014-11-30T16:26:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 1, 2014, 8:53pm UTC](https://forum.ansible.com/t/conditional-include-at-playbook-level-would-be-great/16920/2 "2014-12-01T20:53:06Z")

</div>

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.
