• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Ansible Tower / AWX – Passing Variables using SURVEY (extra-vars)

March 19, 2019 By Cloud_Devops 8 Comments

Ansible Tower’s Survey one of the cool feature which can be used to populate the variables every time the Template is executed. Ansible playbook might contain one more user variable depends on the use cases.  If you want to attach such playbook in AWX / Ansible Tower template, you need to pass the variables in the  “EXTRA VARIABLES” box. In the newer version of Ansible Tower /AWX offers “Survey”.  It’s prompt for Extra Variables in a user-friendly way (Question and answers). Surveys also allow for validation of user input. You could also hide the input variable to mask specific input like security tokens or passwords.

Let’s walk through about Ansible Tower’s Extra variable input & Survey.

 

1. Login to Ansible Tower / AWX as privileged user.

 

2. Here is my sample playbook which requires a variable called “FS_MOUNTPOINT”

---
- hosts: all
  gather_facts: no

  tasks:
  -  name: Root FS usage
     shell: df -h {{ FS_MOUNTPOINT }} |awk ' { print $5 } ' |grep -v Use
     register: dfroot

  -  debug:
       msg: "System {{ inventory_hostname }}'s root FS utiliation is {{ dfroot.stdout }}"

 

To run this playbook from ansible engine, you might need to use the following command.

# ansible-playbook -i temp.hosts Unix_Arena_Demo_df.yaml -e "FS_MOUNTPOINT=/boot"
  • temp.hosts – inventory
  • -e = extra variable. (FS_MOUNTPOINT=/boot)

 

3. Here is my Ansible Tower/ AWX template configuration.

Creating New Template - Ansible - rootfs usage
Creating New Template – Ansible

 

Option: 1   – Passing Variable in Extra Variable box

4. Here is the one of the method to pass the variable on ansible template.   (Older versions)

  • Mark extra variable box to prompt on launch
  • Update the variable key in the extra variable box.
Ansible Tower Template - Extra variable
Ansible Tower Template – Extra variable

 

Option: 2   – Passing Variable using SURVEY

5.  On newer version of Ansible Tower/ AWX, you will get “SURVEY” option to configure.  Open the template and click on “Add Survey”.

Ansible Tower - Enable Survey
Ansible Tower – Enable Survey

 

6. Enter the survey details for our variable – “FS_MOUNTPOINT“.  Selected the “Answer type” as text.

Survey - Select the Answer Type - Ansible
Survey – Select the Answer Type – Ansible

 

7. If the variable is mandatory for the template, please mark it as required.  Click on “Add” to add the first variable to the survey.

Ansible Tower - Survey
Ansible Tower – Survey

 

8. Repeat the same steps if you want to add multiple run-time variables. You could also pass token by selecting Answer type as “password”. So that token will be masked on the jobs.

 

Multiple Survey variable - Ansible Tower - AWX
Multiple Survey variable – Ansible Tower – AWX

 

9. Launch the template to check the configured run time variable.

Launch the template to check Survey - Ansible
Launch the template to check Survey – Ansible

 

10. Here we can see that ansible survey automatically updates the extra variable box. Once you launch this template, ansible-playbook command will be involved in the backend using an extra variable flag.

Survey updates Extra variable - Ansible Tower - AWX
Survey updates Extra variable – Ansible Tower – AWX

 

Hope this article is informative to you.   Share it! Comment it !! Be Sociable !!!

Filed Under: Ansible Tower, Automation, AWX Tagged With: Ansible, Ansible Tower, AWX

Reader Interactions

Comments

  1. Brian Schonecker says

    September 24, 2024 at 12:26 am

    The links to your Github account are broken.

    Reply
  2. Ronny says

    May 16, 2022 at 7:33 pm

    Thanks! good explanation

    Reply
  3. Ziaur Khan says

    June 9, 2021 at 3:23 am

    thank you so much

    Reply
  4. Sounak Choudhury says

    December 22, 2020 at 2:55 am

    Thanks for explaining so simply. Glad that I googled apart from browsing through the docs

    Reply
  5. Michael says

    September 8, 2020 at 11:57 pm

    Is it also possible to apply composite variables to survey prompt values, e.g. enter /opt/{{ mount_point }} in the prompt dialog?
    This is very useful to create Workflows that are more specific to a particular use case, but can still contain parameters.
    Azure DevOps supports this and it’s a very useful feature to have.

    Reply
    • Ivan says

      June 28, 2021 at 5:53 pm

      did you got an answer to this?

      Reply
  6. sam says

    November 15, 2019 at 4:42 am

    Hello,

    Excellent article, Is there any way I can automate survey input value.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version