The AWX Project (AWX) is an open source community project. In addition, it’s the OpenSource version of the Ansible Tower software sponsored by Red Hat, that enables users to better control their Ansible project use in IT environments.
In this tutorial, we’ll provide a step by step instructions about how to create a job template in Ansible Tower / AWX. A job template is a definition and set of parameters for running an Ansible job.
– To create a new job template follow the below steps:
01- Click the templates icon from the left navigation bar.
02- Click the + button then select Job Template from the menu list.
03- Enter the appropriate details into the following fields:
- Name: Enter a name for the job.
- Description: Enter an arbitrary description as appropriate (optional).
- Job Type: Could be Run or Check
- Inventory: Choose the inventory to be used with this job template from the inventories list.
- Project: Choose the project to be used with this job template from the projects list.
- Playbook: Choose the playbook to be launched with this job template from the available playbooks. This menu is automatically populated with the names of the playbooks found in the project base path for the selected project.
- Credential: Click the
searchbutton to open a separate window. Choose the credential from the available options to be used with this job template.
04- Now that you’ve sucessfully created your Job Template, you are ready to launch it, click the rocketship icon:
– Once you do, you will be redirected to a job screen which is refreshing in realtime showing you the status of the job.
Exercice – Creating and Running a Job Template
– If you want to practise, you can use this basic ansible playbook, this playbook install HTTPD and allow the HTTP Protocol on CentOS 7 / RHEL 7 Servers, before proceeding, make sure to create a new credential that have access to the servers with sudo Privilege Escalation.
– Create an ansible playbook under your new project directory like below:
$ sudo -u awx vi /var/lib/awx/projects/YallaLabs_Project01/httpd_install.yml
---
- hosts: all
gather_facts: yes
become: yes
become_method: sudo
vars:
httpd_packages:
- httpd
- httpd-devel
tasks:
- name: 0. RedHat | Check if firewalld is running
command: systemctl is-active firewalld
register: firewalld_result
changed_when: False
ignore_errors: True # rc is 3 when firewalld is stopped
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7"
tags: firewalld_status
- name: 1. RedHat | Yum install httpd
yum:
name: '{{ httpd_packages }}'
state: installed
when: ansible_os_family == "RedHat"
tags: httpd_rhel
- name: 2. Redhat | Ensure httpd is started and enabled
service:
name: httpd
state: started
enabled: yes
- name: 3. RedHat | Allow http Protocol
firewalld:
service: http
permanent: yes
state: enabled
immediate: yes
when: ansible_os_family == "RedHat" and firewalld_result.stdout == "active"
Conclusion
You have learnt the steps to create a new Job Template in AWX Ansible Tower. For more information, you can now visit the official Ansible Tower Documentation page.
See Also:





