After working on Step by Step guide to configure first Project Job Template on Ansible AWX Tower. The most crucial part was configuring Inventory. I wanted a dynamic inventory which can be modified or automatically updated easily. Although there is a dynamic inventory option available on Ansible AWX tower, but I wanted even simpler one where I don't have write a script, Instead I type manual server names in a file and AWX pickup the server hosts from a inventory file. Same thing can be achieved with Github inventory integration source.
It means you can keep inventory file on Github and use it as a inventory hosts or groups without much hassle. Here I have kept hosts named Inventory file on the Github.com, it contains servers list and groups, very easier to update by anyone.
To use the Inventory kept on github, grab the github https url. On the Ansible AWX tower go to the Projects pane from the left side pane and click Add button to create a new project.
Provide a name and description to a Project. Select organization. In the Source Control Credential Type choose Git. In the Type Details area Source Control URL is the git url copied from github code project. Provide Source Control Credential to connect github url although it is optional. Choose Update Revision on Launch if required. In the last Save the project.
Another Article on Install Ansible AWX Tower on Ubuntu Linux OS
Once project is created, make sure it is connected to github and synced the data from git project to Project Base Path /var/lib/awx/projects with Last Job Status Successful message. Go Back to Projects view.
Verify Project is created successfully and listed with Successful status.
Next go to Inventories from left side navigation pane click Add button from drop down list, select Add Inventory.
In the Create new inventory wizard Provide it a name, description and organization. In the last Save it.
Once Inventory is saved and created it will land on the Details tab, from here go to Sources tab and click Add button.
In the Create new source wizard, provide it a name and description. In the Source choose Sourced from a Project. Search and select the Project Name created earlier. Next from the Inventory file choose the hosts (Select the inventory file to be synced by this source. You can select from the dropdown or enter a file within the input) file. Check the box of Update on launch (Each time a job runs using this project, update the revision of the project prior to starting the job.Each time a job runs using this project, update the revision of the project prior to starting the job). Click Save button.
It lands on the Details tab, Here click Sync button to download and update hosts files servers and groups information inside inventory on AWX. Click on the Back to Sources.
Once Sync is completed (It may take some time or you might require to sync it twice or trice). Once back to Inventory click the Hosts tab and verify inventory updated and has the servers list kept and matching on the github.
Another thing can be verified by going to Groups tab and check groups are listed.
Inside the Jobs you can see the Inventory sync jobs are completed successful.
Once inventory is synced and successful, its time to test inventory. For the same Add and configure a New Template with Name, Description, Job Type as Run. In the Inventory choose Github_Inventory_Integration, Select Project where github url is configured. Playbook is a test_ping.yml and below is ping test playbook script. In the playbook hosts I am mentioning one of the group web against I will ping from AWX. Mention the credentials to connect to web servers. In the last Save Template.
---
- name: Check connectivity to remote servers
hosts: web
gather_facts: True
tasks:
- name: ping
ping:
Related Article: Getting started Ansible AWX tower for IT automation run first playbook
Once Template is saved on the details page verify the information and click Launch button.
Once Launch button is pressed, it will go to Jobs, It takes a while to execute a ansible playbook. In the output you can see ping result are successful.
Useful Articles
Getting started Ansible AWX tower for IT automation run first playbook
Ansible for VMwary Using vmware_vm_inventory dynamic inventory plugin
Ansible selectattr The error was TemplateRuntimeError no test named 'equalto'
ansible create an array with set_fact
Ansible get information from esxi advanced settings nested dictionary with unique keynames
Install Ansible AWX Tower on Ubuntu Linux
Ansible AWX installation error Cannot have both the docker-py and docker python modules
Ansible AWX installation error docker-compose run --rm --service-ports task awx-manage migrate --no-input
docker: Got permission denied while trying to connect to the Docker daemon socket
Ansible AWX Tower create Manual SCM (Source Control Credential Type) project
Reset Ansible AWX Tower admin password
Install Ansible AWX on Microsoft Windows OS
Step by Step Install Ansible on Ubuntu OS