# using "with\_items:" in my custom module

**URL:** <https://forum.ansible.com/t/using-with-items-in-my-custom-module/28927>\
**Category:** Ansible Developer\
**Created:** [November 2, 2018, 9:17am UTC](https://forum.ansible.com/t/using-with-items-in-my-custom-module/28927 "2018-11-02T09:17:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shin\_Fukuda](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Shin\_Fukuda](https://forum.ansible.com/u/Shin_Fukuda)\
**Post date:** [November 2, 2018, 9:17am UTC](https://forum.ansible.com/t/using-with-items-in-my-custom-module/28927/1 "2018-11-02T09:17:20Z")

</div>

Hi Ansible Developers.

I want to know how to use “with\_items:” loop in my own custom module ?

e.g.

`

tasks:

- name: “Something custom action”  
my\_first\_mod:  
name: “{{ item }}”  
with\_items:
- ‘andres’
- ‘lukas’

`

Any help in where I’ve gone wrong with this would be much appreciated.

- Shin.

---

<div class="post-metadata">

**Author:** ![Sumit\_Jaiswal](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@Sumit\_Jaiswal](https://forum.ansible.com/u/Sumit_Jaiswal)\
**Post date:** [November 2, 2018, 10:31am UTC](https://forum.ansible.com/t/using-with-items-in-my-custom-module/28927/2 "2018-11-02T10:31:51Z")

</div>

Hi Shin,

Following tasks should work as expected, and shall loop over input list by one item each time. Just for reference:

_Using **with\_items** to loop over list:_  
tasks:

- name: loop over items  
debug:  
msg: “{{ item }}”  
with\_items:
- item\_1
- item\_2

_Using **Loop** to loop over list:_

tasks:

- name: loop over items  
debug:  
msg: “{{ item }}”  
loop:
- item\_1
- item\_2

I want to know the issue/error you are facing when you are trying the same with your custom module.

**_Regards,_**  
Sumit Jaiswal  
alias: _justjais_

---

<div class="post-metadata">

**Author:** ![Shin\_Fukuda](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Shin\_Fukuda](https://forum.ansible.com/u/Shin_Fukuda)\
**Post date:** [November 2, 2018, 10:54am UTC](https://forum.ansible.com/t/using-with-items-in-my-custom-module/28927/3 "2018-11-02T10:54:09Z")

</div>

Hello _justjais._

Thank you for your reply.  
Check it again my playbook, I missed some…, “with\_items:” indent issue. **jumping to conclusion!**

Case closed.

2018年11月2日金曜日 19時32分03秒 UTC+9 Sumit Jaiswal:
