Site icon UnixArena

Ansible Tower / AWX – Creating New Job Template

AWX Logo - Creating Template

AWX Logo - Creating Template

Ansible Job template is used to incorporate the playbook in the web interface. Before start creating the template, you must create the playbook and keep it ready in the project path.  We also need to create other objects like inventory, projects, and credentials to create a new job template. In this article, we will walk you through the job template creation and running the job template from AWX/Ansible Tower console.

 

1. Login to AWX/Ansible Tower console with admin privileges.

 

2. In this demo, we will be using the following inventory to create the ansible job template.

Ansible – Host Inventory information

 

3.  The following playbook will be used on the template. If you do not have the playbook, please create it in the following location. (If you use AWX and followed this tutorial )

[root@ansible-server ~]# cd /var/lib/awx/projects/UnixArena_Project/
[root@ansible-server UnixArena_Project]#
[root@ansible-server UnixArena_Project]# ls -lrt
total 4
-rw-r--r-- 1 root root 255 Nov 26 22:32 Unix_Arena_Demo_df.yaml
[root@ansible-server UnixArena_Project]# cat Unix_Arena_Demo_df.yaml
---
- hosts: all
  gather_facts: no

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

  -  debug:
       msg: "System {{ inventory_hostname }}'s root FS utiliation is {{ dfroot.stdout }}"
[root@ansible-server UnixArena_Project]#

 

4.  Navigate to the template on AWX/Ansible Tower console and click on “+” to create a new template.

Creating New Template – Ansible

 

5. Enter the required template details.  (*)

Creating New Template – Ansible – rootfs usage

 

Here is how I have selected the credentials for the template.

Selected Machine credentials – Ansible Template

 

6. Save the Ansible/AWX template.  To check the disk utilization, we don’t need the privilege escalation.

Save the template – Ansible

 

7. Launch the ansible template.

Launch Ansible / AWX Template

 

10. Once the job is completed, you can see like below with disk utilization message.

Ansible Job status – Success

 

We have successfully created the first ansible job template and ran successfully. Similarly, you could integrate many playbooks into Ansible Tower/AWX.

Exit mobile version