Suraj,

I've been trying to find a way to do this as well, with no luck so far.

Ideally, I'd be able to use a loop (either with_items, or with_dict) to run 
multiple and differing roles on a per-host basis. But, alas, this is not a 
feature and from what I can find from older posts, will not be a feature. 
Passing in a list variable to "roles:" is a good idea, but it doesn't seem 
like Ansible can use variables (even extra-vars from the ansible-playbook 
command) to determine which roles are to be used.

I realize that this may not be considered "best practice", but looping 
through roles and/or include statements would be a MUCH welcome feature.

Chip


On Thursday, January 29, 2015 at 4:18:40 AM UTC-5, Suraj wrote:
>
> Can somebody please help me on this one??
>
> On Wednesday, January 21, 2015 at 10:44:40 PM UTC+5:30, Suraj wrote:
>>
>> I think with this I am still setting every configuration related to one 
>> service in single var file so this way I am maintaining state of the 
>> service at one place and every common thing for all the services will be 
>> written in single playbook.
>>
>> On Wednesday, January 21, 2015 at 10:35:28 PM UTC+5:30, Jonathan Davila 
>> wrote:
>>>
>>> Seems to be sort of an anti-pattern to do it this way. Referencing: 
>>> https://groups.google.com/forum/#!msg/ansible-project/CPAE8_0YXMg/Az3Etfz7mP8J
>>>  
>>>  
>>>
>>> It sounds like a similar issue at the end.
>>>
>>>
>>> On Wednesday, January 21, 2015 at 11:48:55 AM UTC-5, Suraj wrote:
>>>>
>>>> Hi Folks,
>>>>
>>>> I am trying to create single playbook for every service we have. So 
>>>> here we need to deploy multiple roles on different service instance.
>>>> What I want is that, I want to just define variable in different group 
>>>> vars files and depending upon that variable, playbook should run the roles 
>>>> like:
>>>>
>>>> if we have service A which has variable like:
>>>> roles:
>>>> - common
>>>> - roleA
>>>>
>>>> and service B has:
>>>> roles:
>>>> - common
>>>> - roleB
>>>>
>>>> now single playbook should run use these variables and depending upon 
>>>> value it should sun respective roles on respective service instances like:
>>>>
>>>> playbook.yml
>>>>
>>>> ....
>>>>
>>>> roles:
>>>>   - { role : "{{ item }}" }
>>>> with_items:
>>>>   - roles
>>>>
>>>> But it is not working as I want, it give me error:
>>>> "*ERROR: with_items is not a legal parameter at this level in an 
>>>> Ansible Playbook*"
>>>>
>>>> Any Ideas how can I achieve the same using conditions in playbook??
>>>>
>>>> Best Wishes,
>>>> Suraj
>>>>
>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d1041065-a611-42b8-b2d6-3dcc1acb325c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to