# Roles vs Playbooks vs Groups

**URL:** <https://forum.ansible.com/t/roles-vs-playbooks-vs-groups/25013>\
**Category:** Ansible Project\
**Created:** [July 18, 2017, 12:39pm UTC](https://forum.ansible.com/t/roles-vs-playbooks-vs-groups/25013 "2017-07-18T12:39:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Fritz](https://avatars.discourse-cdn.com/v4/letter/h/7ea924/32.png) [@Hans\_Fritz](https://forum.ansible.com/u/Hans_Fritz)\
**Post date:** [July 18, 2017, 12:39pm UTC](https://forum.ansible.com/t/roles-vs-playbooks-vs-groups/25013/1 "2017-07-18T12:39:27Z")

</div>

I’m confused about roles vs playbooks vs groups in the inventory.

I have written a role that I called base. It’s a role I that configures any box I want to use, it sets basic things like the SSH server, automatic updates, etc.

In my inventory, I have a host (boole) that I want to have the base role, and some NFS shares (using an off the shelf NFS role). I also have another host (einstein) that I want to have the base role, and say, a web server (using an off the shelf nginx role).

How do I go about playbooks in this case? Do I name my playbook `boole`, and the other `einstein`? Or do I name them `nfs-server`, and `web-server`? Do I use `hosts: all` in my playbooks and specify the hosts/groups when invoking the playbook, or do I use the group/hosts’ names in the playbook and use `all` when invoking the command line playbook run?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 18, 2017, 1:19pm UTC](https://forum.ansible.com/t/roles-vs-playbooks-vs-groups/25013/2 "2017-07-18T13:19:48Z")

</div>

So this is the 'short' story:

Playbook = contains Plays

Inventory = definition of your targets (where)

Task = ensures an action (what)

Play = maps hosts to tasks (decides what runs where)

Role = grouping of tasks, vars and other resources for reuse  
(optional, roles are a convenience)

As to how to setup plays/hosts: entries, that depends on your  
environment and workflow.  
Ansible allows for many variations so it is valid to have hosts: all  
and then use --limit to target specific hosts or be specific in the  
play hosts: web-server.

My choice would be to create a play for each group and apply the tasks  
and roles you want for that group, then you can create a playbook that  
includes all these.  
This gives you flexibility of 'full system execution' or 'specific  
subsystem' by selecting which playbook, there are other ways to do  
this (i.e tags) but IMHO this is the simplest.
