How to execute a particular role of ansible

ansibleubuntu-14.04

For example i have created the following roles sqldb, rabbitmq, keystone and in the main playbook file i've mentioned all of the three roles, but while executing main playbook using ansible-playbook command i want only a particular role to be executed like for example: keystone role but not sqldb, rabbitmq roles.

One way which i know of is to comment the lines containing the roles sqldb, rabbitmq in main playbook but is there a way directly from the command line using ansible-playbook?

Best Answer

You can add tag for each role you include on the playbook and then when running ansible-playbook use the --tags option.

http://docs.ansible.com/ansible/playbooks_tags.html

PS- For reference (from SO): https://stackoverflow.com/questions/23945201/how-to-run-only-one-task-in-ansible-playbook