Skip to main content

Setting up Ansible Tower (AWX)

Guangzhou, China

Creating a GitHub/GitLab SCM Project

Gitlab Credentials

Ansible Tower allows us to use a Git repository as the source for our Ansible Playbooks. To be able to use this feature we need to add our Gitlab credentials (if you are using the hosted service by Gitlab or Github please refer to the Ansible docs - this is only for privately hosted Gitlab installations). Start by generating an SSH keypair:

cd ~/.ssh
ssh-keygen -N '' -f awx_ssh_key

Now add your private key to the AWX Source Control Credentials:

cat awx_ssh_key

Setting up Ansible Tower (AWX)

And the public key has to be added to your Gitlab user account:

cat awx_ssh_key.pub

Setting up Ansible Tower (AWX)

Adding the Project

We can now use these credentials to add a new project - I added a new test repository on Gitlab and will use it as the Source Control URL here:

Setting up Ansible Tower (AWX)

Save the Project and hit Sync - check under Jobs to see if the run was successful:

Setting up Ansible Tower (AWX)

Now that we know that Ansible Tower has access to our Gitlab repo, we can start by building our Ansible Playbook. Here is an Hello World example:

Setting up Ansible Tower (AWX)

This will simply try to connect to our server, write a Hello World string into the terminal and return a successful if everything worked.

Adding Hosts

To run our playbook we now have to add a host to Ansible Tower. To add a new host to our AWX frontend we need to create an inventory in the Resources/Inventories menu:

Setting up Ansible Tower (AWX)

After saving the inventory, we can add a host (minion server) from the Host tab:

Setting up Ansible Tower (AWX)

Now we need to switch to the Resources/Credentials menu and add our server login:

Setting up Ansible Tower (AWX)

Running our Playbook

Now we are finally at the point were we have all the information collected that Ansible Tower needs to work. So let's bring everything together in a Job Template and see if it runs:

Setting up Ansible Tower (AWX)

Clicking on Launch will run our job template:

Setting up Ansible Tower (AWX)

Success!