Virtual Geek

Tales from real IT system administrators world and non-production environment

Ansible AWX Tower Github inventory integration | Github inventory source

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, it contains servers list and groups, very easier to update by anyone. redhat ansible awx tower hosts inventory https ssh download zip git yml yaml github integration yaml yml.png

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.

Ansible AWX Tower templates credentials projects inventories hosts dashboard jobs schedules activity workflow approvals demo projects yml yaml devops playbook github inventory integration,inventory source host github.png

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

Redhat Ansible awx-operator awx tower github inventory integration default execution environment source control credential type organization branch tag commit update revision on launch yml yaml.png

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.

Ansible AWX Tower awx-operator inventory integration projects tempaltes credentials source control github inventory integration hosts dynamic inventories yml yaml devops.png

Verify Project is created successfully and listed with Successful status. projects github inventory integration gitlab bitbucket litcode mercury git ansible awx tower awx-operator minikube kubernetes k8s k3s automation yml yaml.png

Next go to Inventories from left side navigation pane click Add button from drop down list, select Add Inventory

ansible tower awx add inventory add smart inventory hostname resources templates credentials projects inventories hosts dashboard jobs schedules activity stream workflow approvals.png

In the Create new inventory wizard Provide it a name, description and organization. In the last Save it.

redhat ansible awx tower create new inventory dynamic inventory instance groups organization inventories templates credentials hosts yml yaml devops.png

Once Inventory is saved and created it will land on the Details tab, from here go to Sources tab and click Add button.

Ansible tower awx sources inventories not inventory sources found github inventory integration tempaltes credential type projects inventories hosts.png

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.

Ansible awx create new source inventory projects credentials templates varbosity enabled value enabled variable inventory file github inventory source execution environment.png

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.

Ansible awx tower inventories dynamic github inventory source integarion sources from a project yaml json sync update on lauch hosts templates credentials projects yml playbook yaml devops .png

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.

github inventory hosts anisble awx tower github inventory integraion run command hosts inventories projects credentials templates awx-operator redhat anisble awx k8s kubernetes minikube.png

Another thing can be verified by going to Groups tab and check groups are listed.

Ansible dashboard awx tower jobs schedules activity stream workflow approvals templates resources credentials projects inventories hosts source control integration devops yml yaml.png

Inside the Jobs you can see the Inventory sync jobs are completed successful.

Ansible awx tower awx-operator jobs schedules redhat anisble portal activity stream workflow approvals templates credentials projects inventories hosts organizations users teams yml yaml.png

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
    - name: ping

Related Article: Getting started Ansible AWX tower for IT automation run first playbook

Ansible AWX tower redhat resources templates credentials projects job type inventory project execution environment credentials variables job slicing launch instance groups.png

Once Template is saved on the details page verify the information and click Launch button.

Ansible AWX Tower dashboard jobs schedules resources Templates credentials projects inventories hosts groups github yml yaml devops launch project job type administration.png

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.

Ansible Tower awx dashboard output jobs redhat ping module playbooks gathering facts play recap unreachable credential type templates projects inventories hosts organization applications.png

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

Go Back


Blog Search

Page Views


Follow me on Blogarama