Today I was using Ansible’s tower_job_template module in a playbook. I needed to add extra variables to the job template, but Ansible’s public documentation of the the tower_job_template module had no examples of how to do this. I was unable to find any compelling examples on Google.

I was a bit of poking around the Ansible API, it turns out this was far easier than I had anticipated.

Without further ado, here’s how you use extra_vars_path:

  1. Copy a YAML file to your destination server.
    • This file is just straight up YAML with no additional content.
    • You can use the copy or template module to do this.
  2. Provide the path to the file in extra_vars_path.


Here’s our YAML file (contained within the Ansible role):

  sub_key_1: value_1
  sub_key_2: value_2
  sub_key_3: value_3
  sub_key_4: value_4

And here’s the playbook which (a) copies the file to the server and (b) uses it in extra_vars_path:

- name: Copy extra variables file to AWX host for use in below template task
    src: "{{ role_path }}/files/my_vars.yaml"
    dest: "/var/tmp/my_vars.yml"

- name: Create template on Tower / AWX
    ask_limit: True
    name: install webserver on linux
    description: installs nginx
    playbook: playbooks/install_webserver.yml
    extra_vars_path: "/var/tmp/my_vars.yml"  # <-------------- !!!
    credential: my secrets
    inventory: linux servers
    job_type: run
    project: my project
    state: present