# Allow roles to be applied from the command line

**URL:** <https://forum.ansible.com/t/allow-roles-to-be-applied-from-the-command-line/14559>\
**Category:** Ansible Developer\
**Created:** [February 13, 2014, 4:43am UTC](https://forum.ansible.com/t/allow-roles-to-be-applied-from-the-command-line/14559 "2014-02-13T04:43:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Lara\_Tavares](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@Bruno\_Lara\_Tavares](https://forum.ansible.com/u/Bruno_Lara_Tavares)\
**Post date:** [February 13, 2014, 4:43am UTC](https://forum.ansible.com/t/allow-roles-to-be-applied-from-the-command-line/14559/1 "2014-02-13T04:43:22Z")

</div>

Hi there,

I just started using Ansible, and coming from other provisioning tools, I created several different roles.  
On the documentation you are able to run `ansible webservers -m service -a "name=httpd state=running"` and apply a module to several different servers.

The flow I was imagining was that I would be able to choose a set of servers, and with the `ansible` command, apply roles, the same way we apply a module.  
I looked up on the arguments that you could pass to the command, and it does not accept roles.

Asking on IRC, the suggested way was to generate a minimal playbook on the fly, similar to

```auto
---
- hosts: all
role:
- webserver

```

I think it is not the ideal way. It is more of a workaround and reflects that roles are not first-class concepts on Ansible.  
I thought that we could add `--role` option to `ansible` command, or even create a `role` module that apply roles.

As I just start with Ansible, I am not familiar with the code base as well as the ways you can extend Ansible (eg: modules).

How do you see this working? Where do you suggest to start digging into?  
I would love to help on this and hear suggestion on where to start.

Cheers,

---

<div class="post-metadata">

**Author:** ![Bruno\_Lara\_Tavares](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@Bruno\_Lara\_Tavares](https://forum.ansible.com/u/Bruno_Lara_Tavares)\
**Post date:** [February 13, 2014, 2:44pm UTC](https://forum.ansible.com/t/allow-roles-to-be-applied-from-the-command-line/14559/2 "2014-02-13T14:44:03Z")

</div>

Hi there,

I took a look on the code to see how it could be done and I felt a bit overwhelmed by it.

I then wrote a bash script that generates a temporary playbook with just the role, executes ansible-playbook and removes it.  
I will leave the link for future reference [https://github.com/bltavares/dot-files/commit/54958fc1d6c039c26aa82d8efdd10d701bd7e3a3](https://github.com/bltavares/dot-files/commit/54958fc1d6c039c26aa82d8efdd10d701bd7e3a3)

Cheers,

---

<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:** [February 13, 2014, 4:00pm UTC](https://forum.ansible.com/t/allow-roles-to-be-applied-from-the-command-line/14559/3 "2014-02-13T16:00:51Z")

</div>

Yep, runner is not where the role and playbook logic is maintained, so this would be the way to go if you wanted this.
