# Iterate through user input data

**URL:** <https://forum.ansible.com/t/iterate-through-user-input-data/23332>\
**Category:** Ansible Project\
**Created:** [December 24, 2016, 9:37pm UTC](https://forum.ansible.com/t/iterate-through-user-input-data/23332 "2016-12-24T21:37:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Jaad](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Ahmed\_Jaad](https://forum.ansible.com/u/Ahmed_Jaad)\
**Post date:** [December 24, 2016, 9:37pm UTC](https://forum.ansible.com/t/iterate-through-user-input-data/23332/1 "2016-12-24T21:37:14Z")

</div>

Im a newbie to ansible, and im trying to write an ansible script which would continuously prompt user to insert data and use the data to perform some tasks until the user decides to end the loop, a shell script serving the same purpose would look like this.

```auto

read -s -p "Create new directory? y/n: " response while [["$response" == "y"]] do read -s -p "Enter the name of direcory: " name mkdir $name if [$? -ne 0] then echo "Failed to create new directory $name" exit 1 fi read -s -p "Create another new directory? y/n: " response done

```

```auto
so how do i go about this?

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 29, 2016, 12:35pm UTC](https://forum.ansible.com/t/iterate-through-user-input-data/23332/2 "2016-12-29T12:35:03Z")

</div>

It's not possible with Ansible, Ansible have prompts  
[https://docs.ansible.com/ansible/playbooks\_prompts.html](https://docs.ansible.com/ansible/playbooks_prompts.html)  
But this is question you will have to ask and answer upfront before playbook the rest of the playbook get executed.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 5, 2017, 6:50pm UTC](https://forum.ansible.com/t/iterate-through-user-input-data/23332/3 "2017-01-05T18:50:24Z")

</div>

The `pause` module can prompt and use the responses for a more ‘interactive’ play. So for example, you can use `stat` to check if the directory exists and `pause` to ask what to do next.
