Got it:

- { role: some-services, service: "{{ services[0] }}", when: services.0 is 
defined }
- { role: some-services, service: "{{ services[1] }}", when: services.1 is 
defined }



On Saturday, January 10, 2015 at 11:45:07 AM UTC-8, Peter Mooshammer wrote:
>
> just an update:
>
>
>   - name: debug {{ services[0]['hostname'] }}
>     debug: msg={{ services[0]['hostname'] }}
>     when: services[0] is defined
>   - name: debug {{ services[3]['hostname'] }}
>     debug: msg={{ services[3]['hostname'] }}
>     when: services[3] is defined
>
> This, it is just not working as a conditional for roles....
>
>
>
>
> On Saturday, January 10, 2015 at 11:29:33 AM UTC-8, Peter Mooshammer wrote:
>>
>> I think Tomasz it correct, it was working. Changed it anyways so people 
>> don't get confused.
>>
>>
>> One more question. I tried:
>> And I wanted to use a loop to create those services, but now I am  doing 
>> this:
>>     - { role: some-services, service: "{{ services[0] }}", when: services[0] 
>> is defined }
>>     - { role: some-services, service: "{{ services[1] }}", when: services[1] 
>> is defined }
>>
>> or 
>>
>>   - { role: some-services, service: "{{ services[0] }}", when: "{{ 
>> services[0] }}" is defined }
>>   - { role: some-services, service: "{{ services[1] }}", when: "{{ 
>> services[0] }}" is defined }
>>
>> But none of that is working, this however works:
>> - { role: some-services, service: "{{ services[1] }}", when: simple_var 
>> is defined }
>>
>> thanks 
>>
>> Peter
>>
>>
>> On Saturday, January 10, 2015 at 3:03:16 AM UTC-8, Tomasz Kontusz wrote:
>>>
>>> On 10.01.2015 01:38, Brian Coca wrote: 
>>> > there is not currently a way to loop through roles, you can make the 
>>> > role accept a list and have it's tasks loop over it though. 
>>> > 
>>> > also i would advice to not use a variable named 'service' as it can 
>>> > conflict with the module of the same name. 
>>> > 
>>> > 
>>> I'm pretty sure modules and actions live in a different name space than 
>>> variables. Or do you mean visually? 
>>>
>>

-- 
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/2c56f8cc-6d13-4636-b02b-84b66a301bce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to