By David Rojas
I have a working playbook using roles to create a router config based on the varisables I statically put in but want to have it prompt me for those values. I’ve tried using vars_prompt but doesn’t seem to work I think I’m not putting those commands in the right place.So basically is there a way to do this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
There is an example which you have probably seen at https://github.com/ansible/ansible-examples/blob/master/language_features/prompts.yml which uses vars_prompt which may be helpful as a reference.
I usually use the debug module if I am unsure if a variable is reading in the proper values. You’ve probably used that module before, but the documentation for that is at https://docs.ansible.com/ansible/latest/modules/debug_module.html.
Based on the above examples, one test that you could use might look like this:
---
- hosts: localhost
vars_prompt:
- name: "some_password"
prompt: "Enter password"
tasks:
- debug:
msg: "{{ some_password }}"
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.