# "with\_item" clause support for list variables ?

**URL:** <https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576>\
**Category:** Ansible Project\
**Created:** [May 25, 2012, 7:40am UTC](https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576 "2012-05-25T07:40:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kumar3](https://avatars.discourse-cdn.com/v4/letter/k/ebca7d/32.png) [@Kumar3](https://forum.ansible.com/u/Kumar3)\
**Post date:** [May 25, 2012, 7:40am UTC](https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576/1 "2012-05-25T07:40:55Z")

</div>

Hi :

&nbsp;&nbsp;I am trying to pass a array variable to an task with "with\_item"  
clause, and would like to know whether there is support for this or  
any other alternative ways.

Thanks,

- name:print eth  
&nbsp;&nbsp;action: command echo $item  
&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-$ansible\_interfaces

Output

TASK: [print eth] \*\*\*\*\*\*\*\*\*

ok: [192.168.0.15] =\> command echo $item

ok: [192.168.0.14] =\> command echo $item

ok: [192.168.0.13] =\> command echo $item

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 25, 2012, 11:27am UTC](https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576/2 "2012-05-25T11:27:13Z")

</div>

Which version of Ansible are you running?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 25, 2012, 11:32am UTC](https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576/3 "2012-05-25T11:32:39Z")

</div>

So with\_items taking a variable doesn't presently exist. It must take  
an explicit list.

FWIW, When it does, it would look like this:

with\_items: $ansible\_interfaces

Because a list of one item containing a list of multiple items  
wouldn't make sense.

There's a ticket already open for this feature.

---

<div class="post-metadata">

**Author:** ![Fred\_Alger](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@Fred\_Alger](https://forum.ansible.com/u/Fred_Alger)\
**Post date:** [June 5, 2012, 9:04pm UTC](https://forum.ansible.com/t/with-item-clause-support-for-list-variables/11576/4 "2012-06-05T21:04:01Z")

</div>

By the way, I discovered that you can use YAML’s “repeated nodes”[1] feature to repeat a piece of the current YAML doc’s tree in multiple places.
