# Conditional Includes, Roles and Multiple Playbooks

**URL:** <https://forum.ansible.com/t/conditional-includes-roles-and-multiple-playbooks/15617>\
**Category:** Ansible Project\
**Created:** [July 7, 2014, 3:39pm UTC](https://forum.ansible.com/t/conditional-includes-roles-and-multiple-playbooks/15617 "2014-07-07T15:39:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Garrett](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@Ryan\_Garrett](https://forum.ansible.com/u/Ryan_Garrett)\
**Post date:** [July 7, 2014, 3:39pm UTC](https://forum.ansible.com/t/conditional-includes-roles-and-multiple-playbooks/15617/1 "2014-07-07T15:39:06Z")

</div>

I am trying to figure out the structure for how I am going to use Ansible and am having some design issues.

I would like to have multiple playbooks in my roles, each with a subset of tasks I need to be done. E.g. - a playbook for System Updates, a playbook for deploying our app, a playbook for building a system.

Right now, I have playbooks in place with conditional includes in each roles main.yml file.

In my books/ directory I have my playbook for each role, and here is an example of the whole series of playbooks:

**// books/dev.yml**

---

<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:** [July 8, 2014, 1:36pm UTC](https://forum.ansible.com/t/conditional-includes-roles-and-multiple-playbooks/15617/2 "2014-07-08T13:36:33Z")

</div>

> I am trying to figure out the structure for how I am going to use Ansible  
> and am having some design issues.
> 
> I would like to have multiple playbooks in my roles, each with a subset of  
> tasks I need to be done. E.g. - a playbook for System Updates, a playbook  
> for deploying our app, a playbook for building a system.
> 
> Right now, I have playbooks in place with conditional includes in each  
> roles main.yml file.

Just as a general tip, "group\_by" usually produces much cleaner output than  
conditional includes.

> In my books/ directory I have my playbook for each role, and here is an  
> example of the whole series of playbooks:
> 
> \*// books/dev.yml\*  
> ---  
> - hosts: dev  
> &nbsp;&nbsp;serial: 1  
> &nbsp;&nbsp;roles:  
> &nbsp;&nbsp;&nbsp;- common-dev
> 
> \*// roles/common-dev/tasks/main.yml\*  
> ---  
> - include: build.yml  
> &nbsp;&nbsp;when: pbook == "build"
> 
> - include: update.yml  
> &nbsp;&nbsp;when: pbook == "update"

I'd try to write your playbook to be a bit declarative so th build and  
update process can be run repeatedly without specifying which is which - it  
just gets it into the desired state.

> So, when I run ansible-playbook, I include --extra-vars="pbook=update",  
> for example. It works great, but I get 'skipping' for every task out of the  
> build.yml playbook.
> 
> I would really like to suppress this, if at all possible. I know what the  
> tasks are not running, but I am afraid of causing confusion as I hand off  
> the actual running of the playbooks to other folks. Is there some better  
> way to be handling this?

Possibly tags, or two top level playbooks, but really the above. A good  
playbook shouldn't specify a build or update step, it should work to bring  
a system to a desired version without knowing if it's the first install or  
just an update.

i.e. it should never assume anything about the state of the remote system  
that it does not infer.
