# how can I include only parts (or subtasks of a role

**URL:** <https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [January 15, 2015, 8:33pm UTC](https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285 "2015-01-15T20:33:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Mooshammer](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Peter\_Mooshammer](https://forum.ansible.com/u/Peter_Mooshammer)\
**Post date:** [January 15, 2015, 8:33pm UTC](https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285/1 "2015-01-15T20:33:27Z")

</div>

Hi,

I have a role that does everything to standup a server on aws - create a network and provision a VM. But sometimes I only want to run only the part that deploys a new server.

Currently I simple include these sub-tasks in a playbook, which I don’t really like:

tasks:

# should be called as a role, but only parts of it …

- include: aws/tasks/provision-net.yml
- include: aws/tasks/provision-vm.yml

thanks

Peter

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [January 15, 2015, 8:59pm UTC](https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285/2 "2015-01-15T20:59:15Z")

</div>

Could you use

ansible-playbook --start-at-task

---

<div class="post-metadata">

**Author:** ![Timothy\_Gerla](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Timothy\_Gerla](https://forum.ansible.com/u/Timothy_Gerla)\
**Post date:** [January 15, 2015, 8:59pm UTC](https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285/3 "2015-01-15T20:59:40Z")

</div>

Hi Peter,

I’ve found that when you start wanting to invoke sections of a role independently, that’s usually the time that you should break that role up into multiple separate roles. This makes reuse and separate execution much easier. You can have a structure that looks like this, too:

roles/aws/net/tasks/main.yml  
roles/aws/vm/tasks/main.yml  
…for nice nested organization of roles.

You can then call the roles individually, and if you need to, use role dependencies to enforce one to run before another.

Hope this helps,

-Tim

---

<div class="post-metadata">

**Author:** ![Peter\_Mooshammer](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Peter\_Mooshammer](https://forum.ansible.com/u/Peter_Mooshammer)\
**Post date:** [January 15, 2015, 10:51pm UTC](https://forum.ansible.com/t/how-can-i-include-only-parts-or-subtasks-of-a-role/17285/4 "2015-01-15T22:51:30Z")

</div>

Hi Tim,

that is what I actually did,

so thanks

Peter
