Getting Started: Tower Projects and Inventories

May 26, 2017 by Jake Jackson

Getting-Started-ProjectAndIventories.png

Welcome to another post in our Getting Started series. In our previous post, we discussed how you can equip your Ansible Tower instance with users and credentials.

In this post, we will discuss how to set up projects and inventories in your Ansible Tower instance.

What is a Tower Project?

Tower projects are a logical collection of Ansible Playbooks that are set up with each other based on what they might be doing or which hosts they might interact with.

Playbooks can be managed within Tower projects by either adding them manually to the project base path on your Tower server, (/var/lib/awx/projects) or by importing them from a source control management system (SCM) that is supported by Tower. Examples of SCMs supported by Tower are Git, Subversion and Mercurial. Managing your projects with an SCM is recommended to ensure that only users with assigned access to the repository can change the Playbook before execution, and for the extra layer of accountability and change control it provides. If your Playbooks are managed by an SCM, update options can be selected to “update on launch”, “delete on update” and “clean”.

If you select “update on launch", Tower will sync each time that project is launched and check in to make sure that the most up-to-date Playbooks are running. Selecting "clean" clears out old managed files and unmanaged files in the directory for that project. Selecting “delete on update” will delete the local repository in its entirety prior to performing an update.

How to Create a Project

1. Click the Project link at the top of your Tower instance and select the “+Add” button. 

 snip2.png

2. Upon arriving to the new project page, name the project and select what organization within your instance will be using this project.

3. Select the source for this project, whether that be locally or through an SCM. (Don’t forget that the base path where projects are stored is /var/lib/awx/projects)

 snip3.png

4. Once you have declared the source, you can select "clean", "delete on update" and "update on launch" from the SCM update options.

 snip4.png

Once you have the correct source and you have selected the options you need, hit the save button and you will be returned to the Projects page with your new project listed.

What is a Tower Inventory?

Now that you have set up a Tower project, all you need is some hosts (nodes) to automate and you will be cooking with gas. Within Tower, the hosts that you interact with are set up as collections within Tower called inventories. Tower divides inventories into groups and the groups are what contain the actual hosts. Groups can be sourced manually by adding the IPs and hostnames into Tower, imported from an Ansible hosts file, or they can be sourced from one of Ansible Tower’s supported cloud providers.

If you choose to go the route of using a dynamic inventory source (which is a very popular path), don’t forget you will need to create credentials to get access to your specific provider if your inventory source is a cloud source. If you have an external source of truth for your infrastructure (whether it is a cloud provider or a local CMDB), it is best to define an inventory sync process and use Tower’s support for dynamic inventory. This ensures your inventory is always up to date.

For more on what is included with dynamic inventories in Tower, check out these docs.


Adding a Static Inventory

For the purpose of this blog post, I will go through the steps to add a static inventory to demonstrate the process.

1. To start, from the Tower dashboard, select the inventories header. This will take you to the inventories page where all of your current inventories will be displayed. 

inventory_1-2.png


2. Once there, select the green “+Add” button to create a new inventory. 

inventory_2 (1).png

3. This will open the “Create Inventory” page where you will need to name the inventory and also select which organization it will fall under. 

NEWinventory_3.png

4. Once that is done, select save. (Note: You are not done, your inventory still needs hosts!) 

5. Once you have saved, that specific inventory page will be displayed. (Since this is a brand new one, it will be empty.) 

6. To add a host, simply select the green button that says “+Add Host” 

inventory_6.png

7. This will open the create host page. This is where you will input the host name and any variable definitions and values to be applied to the selected host. 

NEWinventory_7.png

Note that any variables entered must be in either YAML or JSON syntax. You can use the radio buttons above the text box to switch between the two.

Once you have added everything necessary for that host (hostname and any variables), select save and that will add the host to the inventory. You can now view your newly added host in your inventory!

What's Next

I hope this post helps you get started setting up your Tower projects and inventories smoothly.

In the next post in the series, we will go over the steps and requirements needed before you run your first Playbook in Tower, what you will be looking at while the job is running, and the ways you can examine previous job runs to help improve overall performance.

Have any questions from this blog or previous blogs in our Getting Started series? Join one of our monthly "Getting Started Q&A" webinars over here.

Share:

Topics:
Ansible Tower, Product Features, Getting Started


 

Jake Jackson

Jake is a Product Field Engineer at Ansible by Red Hat. Jake started out working as a Systems Analyst where he worked on supporting and maintaining production level application environments. At Ansible by Red Hat, he assists pre sales customers with standing up and getting started with Ansible Tower. He can be found in his spare time either watching soccer or somewhere on the internet. You can find him on Twitter and GitHub as @thedoubl3j.


rss-icon  RSS Feed

Ansible Tower by Red Hat
Ansible In-Depth Whitepaper
Ansible Tower by Red Hat
Learn About Ansible Tower