While creating a provisioning task, I found it difficult to create a "menu-like" structure in Ansible, where you can easily select from a number of options.
Various people online recommended janky hacks which involve wrappers in bash. I wanted an Ansible-native solution.
This might also fall in the category of "janky", but I like it better.
--- - hosts: localhost connection: local gather_facts: no vars_prompt: - name: "server_type" prompt: "\nWhich type of server would you like to deploy?\n1- Oracle\n2- ColdFusion\n3- IIS\n4- Tomcat\n5- File Server\n6- Base Server\n" private: no - name: "environment" prompt: "\nWhich environment will the server reside in?\n1- Production\n2- Staging\n3- DMZ\n" private: no
\n, I was able to separate various options to their own separate lines.
The output now reads as such:
ansible@ansible:~$ ansible-playbook -i inventory provision.yml Which type of server would you like to deploy? 1- Oracle 2- ColdFusion 3- IIS 4- Tomcat 5- File Server 6- Base Server : 1 Which environment will the server reside in? 1- Production 2- Staging 3- DMZ : 1
Much more legible, and easy for users to enter input.