# Oddity with vars\_prompt defaults

**URL:** <https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046>\
**Category:** Ansible Project\
**Created:** [April 18, 2014, 6:41pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046 "2014-04-18T18:41:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Kleckner](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@Jim\_Kleckner](https://forum.ansible.com/u/Jim_Kleckner)\
**Post date:** [April 18, 2014, 6:41pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046/1 "2014-04-18T18:41:24Z")

</div>

See the input and output below for some oddity with vars\_prompt.

First, note that yes is being coerced to True but no results in a missing default.  
Quoting it works around this at the expense of no longer being boolean.

Second, would it make sense to have a boolean option to have vars\_prompt do the smart coercion of yes/no/true/false to boolean?  
I find that the result being a string requires pushing | bool down through the code.

Thanks, Jim

`

---

<div class="post-metadata">

**Author:** ![Jim\_Kleckner](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@Jim\_Kleckner](https://forum.ansible.com/u/Jim_Kleckner)\
**Post date:** [April 18, 2014, 6:56pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046/2 "2014-04-18T18:56:35Z")

</div>

I realize now I should have sent this to the devel list.  
Will send an issue and proposed patch.

`

diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py  
index 1abfe68…cbfd315 100644  
— a/lib/ansible/callbacks.py  
+++ b/lib/ansible/callbacks.py  
@@ -643,7 +643,7 @@ class PlaybookCallbacks(object):

def on\_vars\_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt\_size=None, salt=None, default=None):

- if prompt and default:

- if prompt and default is not None:  
msg = "%s [%s]: " % (prompt, default)  
elif prompt:  
msg = "%s: " % prompt

`

---

<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 23, 2014, 12:58pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046/3 "2014-04-23T12:58:09Z")

</div>

When typing these up, please include an English description of what you expect and what you get, and a short summary, otherwise it can be very difficult to interpret the playbooks.

---

<div class="post-metadata">

**Author:** ![Jim\_Kleckner](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@Jim\_Kleckner](https://forum.ansible.com/u/Jim_Kleckner)\
**Post date:** [April 23, 2014, 11:45pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046/4 "2014-04-23T23:45:49Z")

</div>

Yes, had done that in the issue:  
[https://github.com/ansible/ansible/issues/7057](https://github.com/ansible/ansible/issues/7057)

Do you prefer it in the group in addition?

Jim

---

<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 24, 2014, 2:39pm UTC](https://forum.ansible.com/t/oddity-with-vars-prompt-defaults/15046/5 "2014-04-24T14:39:49Z")

</div>

Just the ticket should be fine, thanks!
