Overview

I often demonstrated how a single person can benefit from Ansible Engine and used the command line tool myself. But there are so many benefits within Tower. It would be a shame not to take advantage of them. If you are part of an organisation with a centrally available Tower instance, that’s fine. If you don’t have access to a tower installation yet, you will be asstonished how easily this is achieved.
The goal of this essay is to set up Ansible Tower for personal usage. As Ansible is the tool to enable “everything as code”, i also aim for automated setup and avoid any manual clicking.
This small little post sets up an Ansible Tower environment as a virtual machine using vagrant and uploads a license file via cmd-line only.

Solution

Prerequisites

I’m running a Mac Book, i have installed vagrant and virtual box.

Download and first start

You find available vagrant boxes here [1] and easily find the relevant ansible/tower vagrant box, which will be used..

Downloading the Tower Box

MacBook:projects mschreie$ mkdir vagrant_tower
MacBook:projects mschreie$ cd $_
MacBook:vagrant_tower mschreie$ vagrant init ansible/tower
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
MacBook:vagrant_tower mschreie$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ansible/tower' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ansible/tower'
    default: URL: https://vagrantcloud.com/ansible/tower
==> default: Adding box 'ansible/tower' (v3.7.1) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ansible/boxes/tower/versions/3.7.1/providers/virtualbox.box
....
MacBook:vagrant_tower mschreie$ vagrant ssh

  Welcome to Ansible Tower!

  Log into the web interface here:

    https://10.42.0.42/

    Username: admin
    Password: xxxxxxxxxxxx 

..
[vagrant@ansible-tower ~]$ 
[vagrant@ansible-tower ~]$ exit

If you want to stop the Tower VM just type:

[mschreie@mschreie ansible_tower]$ vagrant halt
==> default: Attempting graceful shutdown of VM...
[mschreie@mschreie ansible_tower]$

Getting and Uploading a Demo License

Red Hat internal people may get one from here [2], customers from here [3].

I’m preparing some parameters for the upload. The downloaded license file file name will be different at your site:

license_file=/Users/mschreie/Downloads/license_4ab5449a6fd2475eb7000d300fb056ba.txt

user=$(vagrant ssh -c  "bash /etc/profile.d/ansible-tower.sh" | awk '/Username:/ {print $2 }' | tr -d '\r')

password=$(vagrant ssh -c  "bash /etc/profile.d/ansible-tower.sh" | awk '/Password:/ {print $2 }' | tr -d '\r')

curl --user $user:$password --insecure -H "Content-Type: application/json" -X POST -d "$(cat $license_file | sed -e '2i\
\    "eula_accepted": "true",')" https://10.42.0.42/api/v2/config/
{"company_name":"Red Hat","instance_count":50,"license_date":1625307911,"license_key":"de0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","contact_email":"mschreie@redhat.com","contact_name":"Markus Schreier","hostname":"4abxxxxxxxxxxxxx","license_type":"enterprise","subscription_name":"Ansible Tower by Red Hat (50 Managed Nodes), RHT Internal","trial":true,"valid_key":true,"deployment_id":"29axxxxxxxxxxxxxxxxxx","current_instances":1,"available_instances":50,"free_instances":49,"time_remaining":31530675,"grace_period_remaining":31530675,"compliant":true,"date_warning":false,"date_expired":false,"features":{"activity_streams":true,"ha":true,"ldap":true,"multiple_organizations":true,"surveys":true,"system_tracking":true,"rebranding":true,"enterprise_auth":true,"workflows":true}}
[vagrant@localhost ~]$

Be aware after “2i\” must be a new line. The new line again starts with a backslash.

Using Tower

With my favourite web browser i navigated to https://10.42.0.42/ (as given in the output of vagrant ssh, further above) after logging in with the credentials provided through “vagrant ssh“. Ansible Tower is ready to be used.

Conclusion

Setting up an Ansible Tower for personal use is a very easy task as there are vagrant boxes available to be used. If you know the way forward it might not be worth a blog post.

Links / Ressources

[1] https://app.vagrantup.com/ansible/boxes/tower

[2] https://store.ansible.com/redhat/tower_license/

[3] https://www.ansible.com/tower-trial