I'm perhaps not understanding the underlying question, but:

{{ an_array | length }}

will tell you the length of an array in Jinja2




On Wed, Aug 20, 2014 at 8:11 AM, Imran Khan <[email protected]>
wrote:

> Thanks, but to use this I will need to know how many times this task will
> run. That is, in-fact, decided by the person running the playbook, at run
> time
>
>
> On Wednesday, August 20, 2014 5:01:56 AM UTC-7, Michael DeHaan wrote:
>
>> This is easy to experiment with, by constructing a simple playbook:
>>
>> - shell: echo {{ foo }}
>>   with_items: [1,2,3,4,5]
>>   register: result
>>
>> - debug: var=result
>>
>> You will see that the result variable does get registered as an array.
>>
>>
>>
>>
>> On Wed, Aug 20, 2014 at 7:53 AM, Imran Khan <[email protected]> wrote:
>>
>>> What I need is a register array!
>>>
>>>
>>> On Wednesday, August 20, 2014 4:48:17 AM UTC-7, Imran Khan wrote:
>>>
>>>> I would like to know that If I run a task in a loop and save the value
>>>> in a register, how can I save the values so that I have them accessible
>>>> when I need them
>>>> P.S: I am running my playbook using *serial: 1 .* So, when I iterate a
>>>> task, say 5 times, it should save them all seperately, so that when the
>>>> playbook runs serially the second or third time around, I can use the
>>>> registered values as needed.
>>>> Example:
>>>>
>>>> - hosts: just_created_clients
>>>>   serial: 1
>>>>   gather_facts: False
>>>>
>>>> #
>>>> #
>>>>   tasks:
>>>> #
>>>> #
>>>>     - name: Check if the changes to config_file were successful
>>>>       shell: cat /home/imran/Desktop/tobefetched/config_file
>>>>       with_sequence: count=5
>>>>       register: my_content
>>>>       ignore_errors: yes
>>>> #
>>>> #
>>>>
>>>>
>>>> Now, how do I access the values in the register(s) ? Note: I will not
>>>> be immediately using these values, so can't have a task immediately
>>>> following this task, which uses the results of this register sequentially.
>>>> What I need is a register array!
>>>>
>>>  --
>>> 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/abdb1d0d-05e1-4c1a-ba4e-
>>> f63a56ca56b0%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/abdb1d0d-05e1-4c1a-ba4e-f63a56ca56b0%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/06e4b287-486b-480a-8c4e-3f26c2c8d145%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/06e4b287-486b-480a-8c4e-3f26c2c8d145%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/CA%2BnsWgwE%3DCHa5in8vdaKD3syRJQD%2B8LTE%2B1-QU257EzV%3Dv1EHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to