# Add vars\_prompt: to pause module

**URL:** <https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556>\
**Category:** Ansible Developer\
**Created:** [September 25, 2013, 10:27pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556 "2013-09-25T22:27:54Z")\
**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:27pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/1 "2013-09-25T22:27:54Z")

</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.

There is a need for a vars\_prompt that runs later in a play, with access  
to play-generated 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.

In -project, James Cammarata said:

> Regarding [1 and 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.

The problem is that not what to do with the data gathered at  
vars\_prompt. In cases such as the above scenario, the user can only  
learn what to type after the play has generated other variables. So  
the vars\_prompt has to run after other plays, not before as it does  
currently.

In IRC 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.

Sounds good?

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:30pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/2 "2013-09-25T23:30:49Z")

</div>

It seems that to get it to prompt where you want, you’d really need a “vars\_prompt” kind of task.

In this case, while pause does this, I like playbooks to be explicit.

How about making an action plugin called “prompt” ?

Then it would be easy to do this, and while prompt would also pause, it might be more explicit as you could insert this where you needed to go.

I accepted the patch to save the input to the pause module because it’s a one-liner, but I don’t think we need to make it standard.

I think the “prompt” module would be a combination of ideas from both “pause” and “set\_fact”, something of a hybrid.

This way you would also not need to use register with it.

Maybe like

prompt: variable=foo prompt=“enter the self destruct code for {{x}}” ?

I think for most people vars\_prompt is sufficient, but I like the idea that it would be a regular action. OTOH, there’s a lot of stuff about secrets and password re-entry in vars prompt that probably aren’t going to be duplicated here – and maybe should be. Moving them into common functions might be advisable.

–Michael

---

<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 26, 2013, 12:14am UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/3 "2013-09-26T00:14:55Z")

</div>

Hi, Michael. Makes lots of sense. Will try to provide a pull request.

J

---

<div class="post-metadata">

**Author:** ![Kesten\_Broughton2](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Kesten\_Broughton2](https://forum.ansible.com/u/Kesten_Broughton2)\
**Post date:** [February 27, 2014, 8:25pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/4 "2014-02-27T20:25:17Z")

</div>

Did this ever make it in?

I would find a task-level vars\_prompt very handy.

kesten

---

<div class="post-metadata">

**Author:** ![Mridusmita\_Talukdar](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Mridusmita\_Talukdar](https://forum.ansible.com/u/Mridusmita_Talukdar)\
**Post date:** [April 3, 2014, 9:26pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/5 "2014-04-03T21:26:23Z")

</div>

Hi,  
Is there an update on this? When can we expect this feature to be released?  
We need something similar to this.

Thanks,  
Mridu

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 3, 2014, 10:23pm UTC](https://forum.ansible.com/t/add-vars-prompt-to-pause-module/13556/6 "2014-04-03T22:23:44Z")

</div>

Nope,

There’s been a decided emphasis in automation in Ansible and asking questions at task level is not something we really want to do.

However, you can still ask vars\_prompt questions at play level and use those variables throughout tasks. You just can’t ask questions in roles.

And really, that’s what I would like to enforce – if a lot of Galaxy roles start asking questions, I can see that being annoying 🙂
