Vars Module

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

db: postgres

compress: true

engine: postgresql

database_name_2:

user: user

passwd: password

host: 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.

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

Thanks!

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

ansible-devel repost: https://groups.google.com/d/msg/ansible-devel/Eie7uUXgKSA/DdxrVdeCan8J