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
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
Wold definitely appreciate this. Something to automate or bypass vars_prompt. From here, 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?
the default is there for people to hit 'enter' and not have to type,
it also provides an example of the expected input.
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.
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.
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?
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.
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
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.
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
--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.