Exercise 2.1 - Configuring Ansible Tower

Return to Workshop

Exercise Description

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

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

  • Credentials

  • Projects

  • Inventory

  • Job Template

Section 1: Logging into Ansible Tower and installing the license key

Step 1: Log in

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

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

After you login, you will be prompted to request an Ansible Tower license, or browse for an existing license file

at lic prompt
Figure 4: Uploading a License

Step 2: Request workshop license

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

Step 3: Upload Ansible Tower workshop license

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

Step 4: Accept license agreement

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

Step 5: Submit

Select SUBMIT Sub

Section 2: Creating a credential

Credentials are utilized by Ansible 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 Credentials

Select CREDENTIALS, from the left-side menu bar. Cred

Step 2: Select Add

Select ADD Add

Step 3: Complete the Ansible Tower Credentials form

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

cat ~/.ssh/example-tower && echo

NAME

Ansible Workshop Credential

DESCRIPTION

Machine credential for run job templates during workshop

ORGANIZATION

Default

TYPE

Machine

USERNAME

ec2-user

PRIVILEGE ESCALATION

sudo

PRIVATE KEY

paste in secret key

Cred_Detail
Figure 5: Adding a Credential

Step 4: Save

Select SAVE Save

Section 3: Creating a Project

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

Step 1: Open a new project

Select PROJECTS projects.

Step 2: Add the project

Select ADD Add

Step 3: Complete the Project form

Complete the form using the following entries:

NAME

Ansible Workshop Project

DESCRIPTION

workshop playbooks

ORGANIZATION

Default

SCM TYPE

Git

SCM URL

https://github.com/ajacocks/lightbulb

SCM BRANCH

SCM UPDATE OPTIONS

  • Clean

  • Delete on Update

  • Update Revision on Launch

Cred_Detail
Figure 6: Defining a Project

Step 4: Save

Select SAVE Save

Section 4: Creating an 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 Ansible Tower, or from one of Ansible Tower’s supported cloud providers.

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

Select INVENTORIES Inv

Step 2: Add a new inventory

Select ADD Add, and then select Inventory.

Step 3: Complete the Inventory form

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: Save

Select SAVE Save

Step 5: Switch back to your terminal session

Switch back to your terminal session. If by any chance you closed the Red Hat Web Console browser window, open a new one with the URL shown, below:

https://tower-0.example.redhatgov.io:9090/system/terminal

Step 6: Import an existing inventory

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/ec2-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 Ansible Tower, by selecting Hosts. hosts

You should now notice that the inventory has been populated with each each of hosts and corresponding inventory.

Cred_Detail
Figure 9: Inventory with Groups

End Result

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


Workshop Details

Domain Red Hat Logo
Workshop
Student ID

Return to Workshop