I have a site.yml which imports several playbooks.
- import_playbook: webservers.yml
- ....
Every playbook "calls" several roles:
- name: apply the webserver configuration
hosts: webservers
roles:
- javajdk
- tomcat
- apache
How can I run only the javajdk role ?
This would run all roles...
ansible-playbook -i inventory webservers.yml
I know that there are tags, but how do I assign them to a role in general?
Tags are natural way to go. Three ways of specifying them for roles below:
- name: apply the webserver configuration
hosts: webservers
roles:
- role: javajdk
tags: java_tag
- { role: tomcat, tags: tomcat_tag }
tasks:
- include_role:
name: apache
tags: apache_tag
You can explictly specify the tags to run:
ansible-playbook example.yml --tags "java_tag"