Yes i can do that, for example;
- name: do something1
module: parameters
with_sequence: start=0 end={{count}}
- name: do something2
module: parameters
with_sequence: start=0 end={{count}}
- name: do something3
module: parameters
with_sequence: start=0 end={{count}}
- name: do something4
module: parameters
with_sequence: start=0 end={{count}}
- name: do something5
module: parameters
with_sequence: start=0 end={{count}}
and i don't want to do that, because it's not a clever way to iterate
something.
It should be that difficult to iterate a role, that's my point.
Thank you for suggestions.
On Saturday, July 12, 2014 12:29:16 AM UTC+2, Michael DeHaan wrote:
>
> Or you can, but you don't want to? :)
>
>
>
>
> On Fri, Jul 11, 2014 at 5:34 AM, Serkan C. <[email protected]
> <javascript:>> wrote:
>
>> I already use this method to pass variable to roles but in this case
>> role1 has 15 tasks, i cannot iterate all of them one by one.
>>
>>
>> On Thursday, July 10, 2014 9:04:24 PM UTC+2, James Cammarata wrote:
>>
>>> In that case, you'd just pass in the variable as an integer and use that
>>> in with_sequence.
>>>
>>>
>>> On Thu, Jul 10, 2014 at 10:08 AM, Serkan C. <[email protected]> wrote:
>>>
>>>> Thanks for suggestion, it looks like i can find a solution with that
>>>> method.
>>>> I would like to pass just count, a number, how can i do that?
>>>>
>>>>
>>>> On Thursday, July 10, 2014 4:54:05 PM UTC+2, James Cammarata wrote:
>>>>
>>>>> The other way we typically recommend doing this is to pass the array
>>>>> of whatever as a role parameter. For example:
>>>>>
>>>>> roles:
>>>>> - { role: foo, list_of_whatever: [...] }
>>>>>
>>>>> and then loop over that list_of_whatever variable inside the roles
>>>>> tasks.
>>>>>
>>>>>
>>>>> On Thu, Jul 10, 2014 at 7:27 AM, Michael DeHaan <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> "you cannot execute a role conditionally, you CAN pass a condition
>>>>>> to every task in a role."
>>>>>>
>>>>>> True!
>>>>>>
>>>>>> - { role: asdf, when: foo == 'asdf' }
>>>>>>
>>>>>> Another good trick is group_by is a great way to create a small
>>>>>> group of hosts where a given condition is true or false, and then you
>>>>>> just
>>>>>> apply that role to that group.
>>>>>>
>>>>>> - hosts: all
>>>>>> tasks:
>>>>>> - group_by: key=foo_{{ foo }}
>>>>>>
>>>>>> # talk to all hosts where the value of foo is asdf
>>>>>> - hosts: foo_asdf
>>>>>> roles:
>>>>>> - asdf
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Jul 10, 2014 at 7:26 AM, Brian Coca <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> you cannot execute a role conditionally, you CAN pass a condition
>>>>>>> to every task in a role.
>>>>>>>
>>>>>>> role and include directives are basically 'preprocessing macros'
>>>>>>> they are used to include other files into main play.
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 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/CADn%2BHsz
>>>>>>> 6YvdjD1QvrKAP-Pg_yE%2BOmeFKEgAeMGJXVVcy6_oZ-Q%40mail.gmail.com
>>>>>>> <https://groups.google.com/d/msgid/ansible-project/CADn%2BHsz6YvdjD1QvrKAP-Pg_yE%2BOmeFKEgAeMGJXVVcy6_oZ-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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/CA%2BnsWgz2jVy-S%3DDK7NHWty7OV%2BZf2bgr9
>>>>>> %2Bgx1Am3qTMrHA504g%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgz2jVy-S%3DDK7NHWty7OV%2BZf2bgr9%2Bgx1Am3qTMrHA504g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>> --
>>>> 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/3a3e4978-ecea-45fc-bc33-
>>>> 21bbec7d9007%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/3a3e4978-ecea-45fc-bc33-21bbec7d9007%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/23a3507f-3258-4339-a7fd-1c98b684e78e%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/23a3507f-3258-4339-a7fd-1c98b684e78e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/a4ebdcd1-05dc-48da-8355-6558f25b8200%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.