How can I iterate through user input data with "with_items" loop?

65 views
Skip to first unread message

Mario Vázquez

unread,
Feb 17, 2015, 3:52:21 AM2/17/15
to ansible...@googlegroups.com
Hello all,

I need help with a loop iterating through user input data. I have a prompt variable in my playbook that is filled with usernames. The value its something like "test1 test2 test3".

I need to iterate through this values within "with_items" iterator.

If I use with_items: variableName the loop iterates only once (the value was test1 test2 test3).

Any ideas?

Thank you in advance.

Matt Martz

unread,
Feb 17, 2015, 8:32:27 AM2/17/15
to ansible...@googlegroups.com
Try:

with_items: variableName.split()
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2116213a-01dc-465f-800d-791a45c5e351%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Mario Vázquez

unread,
Feb 18, 2015, 3:38:58 AM2/18/15
to ansible...@googlegroups.com
Hello Matt,

It is working with .split().

Thank you very much.


El martes, 17 de febrero de 2015, 14:32:27 (UTC+1), Matt Martz escribió:
Try:

with_items: variableName.split()

On Tuesday, February 17, 2015, Mario Vázquez <vcma...@gmail.com> wrote:
Hello all,

I need help with a loop iterating through user input data. I have a prompt variable in my playbook that is filled with usernames. The value its something like "test1 test2 test3".

I need to iterate through this values within "with_items" iterator.

If I use with_items: variableName the loop iterates only once (the value was test1 test2 test3).

Any ideas?

Thank you in advance.

--
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.
Reply all
Reply to author
Forward
0 new messages