# Add --force to skip var\_prompts and use default values

**URL:** <https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593>\
**Category:** Ansible Developer\
**Created:** [June 24, 2015, 2:09pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593 "2015-06-24T14:09:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Strassle](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christian\_Strassle](https://forum.ansible.com/u/Christian_Strassle)\
**Post date:** [June 24, 2015, 2:09pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/1 "2015-06-24T14:09:58Z")

</div>

Hi Developers,

It would be nice to have something like a --force or --batch option to skip var\_prompts and just go ahead with default values.  
What do you think?

Kind regards,  
Chris

---

<div class="post-metadata">

**Author:** ![Kristopher\_Ruzic](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kristopher\_Ruzic](https://forum.ansible.com/u/Kristopher_Ruzic)\
**Post date:** [June 29, 2015, 12:48pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/2 "2015-06-29T12:48:24Z")

</div>

Wold definitely appreciate this. Something to automate or bypass vars\_prompt. [From here,](http://stackoverflow.com/a/25501250) looks like the developers don’t want a conditional prompt, but just completely skipping them would have the same effect. I want to/need to automate these vars in some cases. What’s the point in default values if you still have to manually assign it?

---

<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:** [June 29, 2015, 12:52pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/3 "2015-06-29T12:52:33Z")

</div>

the default is there for people to hit 'enter' and not have to type,  
it also provides an example of the expected input.

---

<div class="post-metadata">

**Author:** ![Kristopher\_Ruzic](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kristopher\_Ruzic](https://forum.ansible.com/u/Kristopher_Ruzic)\
**Post date:** [June 29, 2015, 12:54pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/4 "2015-06-29T12:54:02Z")

</div>

I know _what_ its there for. I’m saying, if you still have to press enter… that’s not as useful as it could be. As the OP stated, a flag to automatically run through them would be useful.

---

<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:** [June 29, 2015, 12:55pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/5 "2015-06-29T12:55:22Z")

</div>

you also have the option of using the pause module to prompt and get  
user input, this is a task so you can use when: to skip it when  
providing the info in some other way.

---

<div class="post-metadata">

**Author:** ![Kristopher\_Ruzic](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kristopher\_Ruzic](https://forum.ansible.com/u/Kristopher_Ruzic)\
**Post date:** [June 29, 2015, 1:46pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/6 "2015-06-29T13:46:17Z")

</div>

Thanks for the help. I can’t find anywhere to get the user’s input from a pause though. I can register what they enter?

---

<div class="post-metadata">

**Author:** ![Hagai\_Kariti](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@Hagai\_Kariti](https://forum.ansible.com/u/Hagai_Kariti)\
**Post date:** [June 29, 2015, 2:00pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/7 "2015-06-29T14:00:14Z")

</div>

I tried to redirect stdin to a file or /dev/null but that didn’t work as well - seems like ansible is actually opening the attached tty directly, which is unexpected.

---

<div class="post-metadata">

**Author:** ![Christian\_Strassle](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christian\_Strassle](https://forum.ansible.com/u/Christian_Strassle)\
**Post date:** [July 1, 2015, 7:17am UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/8 "2015-07-01T07:17:26Z")

</div>

I guess there are always other ways to accomplish something similar, but are there any other why not to introduce something like --batch / --force? It would certainly feel very natural to the \*nix-community.

Kind regards,  
Chris

---

<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:** [July 1, 2015, 2:53pm UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/9 "2015-07-01T14:53:40Z")

</div>

yes, we can introduce that, i was just suggesting a workaround that is  
available now. registering a var from the pause module and making it  
conditional on the var not being defined seems like it would give you  
what you need right now.

---

<div class="post-metadata">

**Author:** ![Kristopher\_Ruzic](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kristopher\_Ruzic](https://forum.ansible.com/u/Kristopher_Ruzic)\
**Post date:** [July 2, 2015, 8:49am UTC](https://forum.ansible.com/t/add-force-to-skip-var-prompts-and-use-default-values/18593/10 "2015-07-02T08:49:14Z")

</div>

This does what I need it to, so thank you! I appreciate the workaround, hope a full solution is available sometime.

In case anyone is curious as to exactly how to do this:

`

- name: Prompt that is skipped on extra-vars  
pause: prompt=“enter val1, you didn’t skip prompts”  
when: prompt\_1 is not defined  
register: prompt\_1

- name: print off prompt\_1  
debug: var=prompt\_1.user\_input

# to skip over the prompt, pass `--extra-vars '{"prompt_1": {"user_input": "test"}}''` on the command line.

`

Doing this completely replaces the need for vars\_prompt, and let’s you specify a json file even to load the params from. Just make sure to change access to the vars to use var\_name. **user\_input** as that is what the prompt will store it in.
