# vars\_prompt, but in the middle of a play, with access to variables

**URL:** <https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554>\
**Category:** Ansible Project\
**Created:** [September 25, 2013, 10:04pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554 "2013-09-25T22:04:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Candeira](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Javier\_Candeira](https://forum.ansible.com/u/Javier_Candeira)\
**Post date:** [September 25, 2013, 10:04pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/1 "2013-09-25T22:04:49Z")

</div>

I was about to open an issue that the prompt to vars\_prompt did not  
interpolate my variables. Then, after doing a couple more tests, I  
realised it is because vars\_prompt runs very early, before even setup  
does.

Is there something like vars\_prompt that runs in the middle of a play,  
with access to variables? This is my scenario:

1. Play runs, and through its run it creates a var with the name of a  
database it's going to delete.  
2. User gets prompted something like vars\_prompt: db2: "I'm about to  
delete {{db1}}. Enter the db's full name to confirm"  
3. The play only deletes the database when: db1 == db2.

Here are my questions:

1. Can I do what I want with the current ansible modules/lookup plugins?  
2. What would be the sane thing to add to ansible so the above  
workflow is possible?  
3. At which point should this conversation move to -devel?

Thanks,

Javier

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 25, 2013, 10:20pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/2 "2013-09-25T22:20:12Z")

</div>

Last question first: probably now 🙂

Regarding the other 2, it would seem that running the data gathered during the vars\_prompt through the template engine might be the best/easiest solution, though we can continue to discuss it on -devel.

---

<div class="post-metadata">

**Author:** ![Javier\_Candeira](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Javier\_Candeira](https://forum.ansible.com/u/Javier_Candeira)\
**Post date:** [September 25, 2013, 10:20pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/3 "2013-09-25T22:20:33Z")

</div>

And, answering myself: in discussion with drybjed and bbhoss, this is  
a possible solution:

Add the vars\_prompt: type of lookup to the pause module, so pause has  
both prompt: for yes/no, and vars\_prompt: for strings input at the  
keyboard.

J

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [September 25, 2013, 11:27pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/4 "2013-09-25T23:27:47Z")

</div>

Have you looked into the pause module? It is what I use for confirming.

Brian Coca

---

<div class="post-metadata">

**Author:** ![Javier\_Candeira](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Javier\_Candeira](https://forum.ansible.com/u/Javier_Candeira)\
**Post date:** [September 25, 2013, 11:34pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/5 "2013-09-25T23:34:18Z")

</div>

We were discussing the pause module on IRC. We don't want to risk  
people confirming by mistake with a simple \<enter\>; we want users to  
type out the databse to wipe out. Also pause doesn't pause for every  
host: there are rolling updates in which it pauses per group of hosts.

Maybe we need another module that requests user input per individual host.

J

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 25, 2013, 11:58pm UTC](https://forum.ansible.com/t/vars-prompt-but-in-the-middle-of-a-play-with-access-to-variables/13554/6 "2013-09-25T23:58:01Z")

</div>

Hi all,

We all ended up bringing this discussion over to ansible-devel.

If you are interested, try joining there:

[https://groups.google.com/forum/#!forum/ansible-devel](https://groups.google.com/forum/#!forum/ansible-devel)
