Survey the sh*t out of the Ansible Playbooks – Ansible Tower Surveys

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 specific 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.