Exercise 2.1 - Configuring Ansible Tower

Return to Workshop

In this exercise, we are going to configure Tower so that we can run a playbook.

Configuring Ansible Tower

There are a number of contructs in the Ansible Tower UI that enable multi-tenancy, notifications, scheduling, etc. However, we are only going to focus on a few of the key contructs that are required for this workshop today.

  • Credentials

  • Projects

  • Inventory

  • Job Template

Logging into Tower and Installing the License Key

Step 1:

To log in, use the username admin and and the password ansibleWS.

ansible lab figure01 logon screen
Figure 3: Ansible Tower Login Screen

As soon as you login, you will prompted to request a license or browse for an existing license file

at lic prompt
Figure 4: Uploading a License

Step 2:

In a separate browser tab, browse to https://www.ansible.com/workshop-license to request a workshop license.

Step 3:

Back in the Tower UI, choose BROWSE LicB and upload your recently downloaded license file into Tower.

Step 4:

Select "I agree to the End User License Agreement".

Step 5:

Click on SUBMIT Sub

Creating a Credential

Credentials are utilized by Tower for authentication when launching jobs against machines, synchronizing with inventory sources, and importing project content from a version control system.

There are many types of credentials including machine, network, and various cloud providers. In this workshop, we are using a machine credential.

Step 1:

Select the gear icon Gear

Step 2:

Select CREDENTIALS

Step 3:

Click on ADD Add

Step 4:

Complete the form using the following entries, by printing out your private SSH key to place into Tower. When you paste the key in, in the PRIVATE KEY field, make sure to include the -----BEGIN RSA PRIVATE KEY----- and -----BEGIN RSA PRIVATE KEY----- lines.

cat ~/.ssh/example-tower

NAME

Ansible Workshop Credential

DESCRIPTION

Machine credential for run job templates during workshop

ORGANIZATION

Default

TYPE

Machine

USERNAME

azure-user

PRIVILEGE ESCALATION

Sudo

PRIVATE KEY

paste in secret key

Cred_Detail
Figure 5: Adding a Credential

Step 5:

Select SAVE Save

Creating a Project

A Project is a logical collection of Ansible playbooks, represented in Tower. You can manage playbooks and playbook directories by either placing them manually under the Project Base Path on your Tower server, or by placing your playbooks into a source code management (SCM) system supported by Tower, including Git, Subversion, and Mercurial.

Step 1:

Click on PROJECTS

Step 2:

Select ADD Add

Step 3:

Complete the form using the following entries:

NAME

Ansible Workshop Project

DESCRIPTION

workshop playbooks

ORGANIZATION

Default

SCM TYPE

Git

SCM URL

https://github.com/ansible/lightbulb

SCM BRANCH

SCM UPDATE OPTIONS

  • Clean

  • Delete on Update

  • Update on Launch

Cred_Detail
Figure 6: Defining a Project

Step 4:

Select SAVE Save

Creating a Inventory

An inventory is a collection of hosts against which jobs may be launched. Inventories are divided into groups and these groups contain the actual hosts. Groups may be sourced manually, by entering host names into Tower, or from one of Ansible Tower’s supported cloud providers.

An Inventory can also be imported into Tower using the tower-manage command and this is how we are going to add an inventory for this workshop.

Step 1:

Click on INVENTORIES

Step 2:

Select ADD Add

Step 3:

Complete the form using the following entries

NAME

Ansible Workshop Inventory

DESCRIPTION

workshop hosts

ORGANIZATION

Default

Cred_Detail
Figure 7: Create an Inventory

Step 4:

Select SAVE Save

Step 5:

Using ssh, login to your control node, if by any chance you closed the wetty browser window. Remember to replace workshopname with your workshop name, and # with your student number.

https://example-tower0.example.redhatgov.io:8888/wetty/ssh/azure-user

Step 6:

Use the tower-manage command to import an existing inventory. (Be sure to replace <username> with your actual username)

sudo tower-manage inventory_import --source=/home/azure-user/hosts --inventory-name="Ansible Workshop Inventory"

You should see output similar to the following:

Cred_Detail
Figure 8: Importing an inventory with tower-manage

Feel free to browse your inventory in Tower. You should now notice that the inventory has been populated with Groups and that each of those groups contain hosts.

Cred_Detail
Figure 9: Inventory with Groups

End Result

At this point, we are doing with our basic configuration of Ansible Tower. In exercise 2.2, we will be soley focused on creating and running a job template so you can see Tower in action.


Workshop Details

Student ID:
Workshop:
Region:

Domain:
Workshop Name:
Region:
User ID:

Return to Workshop