Ansible – We all know it – Ansible is useful and, in a lot of cases, fun to play with. It also allows the creation of variables which can be changed to parametrise the playbook. When using the standard Ansible Core and Ansible Playbooks, we would usually configure the variables in the main body of the playbook inventory or create variables for a host and/or a group. In Ansible role, we could also use the defaults and variables directories and specify the variables there.
What does Ansible Tower do beyond Ansible Core?
Ansible Tower has a really cool feature which can be used to populate the essential variables every time the “Surveys” Template is executed. Surveys set extra variables for the playbook, similar to the way ‘Prompt for Extra Variables’ does, but in a user-friendly Q&A way. Surveys also allow for validation of user input.
Once a template is created and saved in Ansible Tower, the ‘Edit Survey’ button becomes available:
After clicking on the ‘Edit Survey’ button, the following window will pop-up:
The next step is to Specify the ‘Prompt’, which usually is a question about the content of the variable.
Next field is the Answer Variable Name, where the variable used in the playbook needs to be entered and finally Answer Type. For example:
Once all the Survey Prompts are added, click Save and test the Template.
The following presents the run of the simple Template which extends the File System for the specifc mount point (the playbook verifies the underlying file system).
Once the Template is executed (the Rocket icon), you will be presented with the Survey:
Once all the values are specified, click Launch and the template with new values will be run on the inventory node.
Want these insights delivered straight to your inbox?
ABOUT THE AUTHOR
Consultant | Insentra
I am an IT professional with over 20 years of experience. Within that time I worked for local and global system integrators specializing in many technologies ranging from Network Security to Data Protection. I was involved in design and implementation of Data Protection and Security systems for many banks and government organisations.
I currently work as Senior Consultant at Insentra, being responsible for presales, technical design and implementation of leading class enterprise solutions.
Prior to joining Insentra I enjoyed working for a few global integrators, being responsible for many aspects of technology. I have also good knowledge of European technical vistas and methodologies used there.