Setting up Ansible Tower (AWX)
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
And the public key has to be added to your Gitlab user account:
cat awx_ssh_key.pub
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:
Save the Project and hit Sync - check under Jobs to see if the run was successful:
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:
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:
After saving the inventory, we can add a host (minion server) from the Host tab:
Now we need to switch to the Resources/Credentials menu and add our server login:
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:
Clicking on Launch will run our job template:
Success!