# Vars Module

**URL:** <https://forum.ansible.com/t/vars-module/14627>\
**Category:** Ansible Project\
**Created:** [February 21, 2014, 8:41pm UTC](https://forum.ansible.com/t/vars-module/14627 "2014-02-21T20:41:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_James\_Walker](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kyle\_James\_Walker](https://forum.ansible.com/u/Kyle_James_Walker)\
**Post date:** [February 21, 2014, 8:41pm UTC](https://forum.ansible.com/t/vars-module/14627/1 "2014-02-21T20:41:56Z")

</div>

I have a fews questions:

1. Is there a way to turn on stdout for a task, to allow user prompting?
2. Is there support for creating a ‘vars module’, run before any tasks like vars and vars\_prompt?
3. Any recommendations on another direction to get the desired results mentioned below?

I’m currently looking into creating a custom module that will read a file, take a user’s input, and based on the input create a file on the system, with additional options like not prompting the user if the file already exists on the remote system.

The problem is I can’t find a way to get the stdout to display when prompting the user, and it would be better to have a ‘vars module’ instead of ‘task module’ (run before the playbook, aka the same times vars\_prompt is run).

I could do this with the vars\_prompt, and a template, but then I loose flexibility and of the functionality currently in my app, and have more locations to update when changes are made.

Here’s my example:  
my\_app/defaults.yaml (in revision control): This has all the values that can be overridden, along with some defaults. Some are perfectly fine to keep in revision control, so defaults are usually ok, others are not (passwords, etc).

> # Program Defaults, do not edit this file!!!
> 
> # All values should be overridden in the ‘settings.yaml’ file.
> 
> sample\_config:
> 
> databases:
> 
> database\_name\_1:
> 
> user: user
> 
> passwd: password
> 
> host: [db.example.com:5432](http://db.example.com:5432)
> 
> db: postgres
> 
> compress: true
> 
> engine: postgresql
> 
> database\_name\_2:
> 
> user: user
> 
> passwd: password
> 
> host: [anotherdb.example2.com:5432](http://anotherdb.example2.com:5432)
> 
> db: example
> 
> compress: true
> 
> engine: postgresql
> 
> secret\_key: example hard to guess flask secret key
> 
> more\_values: more\_examples

remote\_location/settings.yaml: Generated by user with, outside revision control. This doesn’t need every values, as I want the defaults left out of this file, so if updated in rev control they won’t be overridden.

> sample\_config:  
> databases:  
> database\_name\_1:  
> user: kyle\_walker  
> passwd: my password is secure  
> database\_name\_2:
> 
> user: sample\_app\_login  
> passwd: the apps password is secure also  
> secret\_key: secure flask secret key

Core logic of my module (work in progress): This would work well enough if the stdout can be enabled. But I think it would be better to be have has run at prompt time, and then use a copy with no source, and this variable data as the default contents, or another custom module.

---

<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:** [February 21, 2014, 9:02pm UTC](https://forum.ansible.com/t/vars-module/14627/2 "2014-02-21T21:02:09Z")

</div>

Since you’re asking code questions, can you please repost this on ansible-devel ?

Thanks!

---

<div class="post-metadata">

**Author:** ![Kyle\_James\_Walker](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kyle\_James\_Walker](https://forum.ansible.com/u/Kyle_James_Walker)\
**Post date:** [February 21, 2014, 9:07pm UTC](https://forum.ansible.com/t/vars-module/14627/3 "2014-02-21T21:07:12Z")

</div>

Thanks, I’ve just posted this in the correct group.

ansible-devel repost: [https://groups.google.com/d/msg/ansible-devel/Eie7uUXgKSA/DdxrVdeCan8J](https://groups.google.com/d/msg/ansible-devel/Eie7uUXgKSA/DdxrVdeCan8J)
