How to run only one role out of a playbook?

35 views
Skip to first unread message

akazi...@gmail.com

unread,
Nov 21, 2017, 8:59:11 AM11/21/17
to Ansible Project
Hello 

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

Now how can I run lets say only the javajdk role ?

ansible-playbook -i inventory/xx  webservers.yml      would run all roles...  I know that there are tags, but how do I assign them to a role in general?

Thanks a lot 
Michael

Mischa ter Smitten

unread,
Nov 21, 2017, 2:08:58 PM11/21/17
to Ansible Project
If you tag the roles, you can use ansible-playbook --tags some-tag

akazi...@gmail.com

unread,
Nov 21, 2017, 2:21:32 PM11/21/17
to Ansible Project
Hello thank,

well I can have - role: javajdk
                           tags: javajdk 

but this tags this role in this ONE palybook. But if I run an other playbook with - role: javajdk there is not tag.
So either I have to tag it every time or, smater, I would tag the role itself. But I have not found a method to do so

Michael 

Brian Coca

unread,
Nov 21, 2017, 4:10:59 PM11/21/17
to Ansible Project
just reference the role directly, its much simpler than calling other
playbooks to just use one of their roles



--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages