Run multiple play books according to role

20 views
Skip to first unread message

ansibl...@gmail.com

unread,
Feb 21, 2018, 9:15:23 AM2/21/18
to Ansible Project
I want to run playbooks according to role

host file will contain all host:groups

if role a and group a:

run playbook a

if role b and group b

run playbook b  etc

Or if we give role in runtime, it will run the playbook corresponding to it

Brian Coca

unread,
Feb 21, 2018, 2:23:55 PM2/21/18
to Ansible Project
Your roles sounds like 'other type of group', i.e webserver, dbserver,
just define those as groups in Ansible. and then:

hosts; rolea:&groupa

^ play runs against hosts in BOTH groups.


In Ansible 'role' means a 'reusable component' that can be
tasks/templates/vars/etc, it is not associated to a host directly,
that is what plays do.


--
----------
Brian Coca

Ansible Krazy

unread,
Feb 22, 2018, 11:28:37 AM2/22/18
to ansible...@googlegroups.com
So what if I want to run playbook a,b,c if group a and c,d,e if group type is b

can it be achieved via one combined playbook


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7fpmuhoM-LS-vU-nTwDqTMRZ95%3DWwmP1DrP_cQ%3D81tSoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Feb 22, 2018, 12:08:34 PM2/22/18
to Ansible Project
you can have many plays per playbook or even include other playbooks
in a playbook, not sure what your combinations above mean, but you
should be able to adjust the hosts: keyword to whatever you want.


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