At the beginning of this project, I started out setting up the foundation for Ansible to automate the management, configuration, deployment, and maintenance of the infrastructure that I set up. That was before the project got kicked into high gear with setting up the server, storage, Kubernetes, and several services on Kubernetes. Now it’s time to come back to that and utilize AWX to handle managing and running Ansible playbooks.

I already have a private Github repository with the work I’ve done so far on Ansible and AWX/Tower can use that repository and keep in sync when it changes. This means I can continue to develop as I have been and check it into Github when it’s ready for production-use. There are other ways to import Ansible inventories into AWX/Tower, but I like this one because it’s keeps in sync and doesn’t move my workflow solely to AWX.

Projects

I already created an organization and made myself the owner of the organization. Within that organization, I will use a project which is sourced from Git SCM (e.g. GitHub). The inventories will be sourced from files in the project. When the repository changes, the project will be updated and the inventories will be imported.

Since I have these inventories in a private Github repository, I will need to create a personal access token in the Github Settings. This will be used in place of my actual Github password since I have two-factor authentication turned on for security. I will go to Credentials and create a new credential of type Source Control with:

  • Name
  • Description
  • Organization
  • Username - Github user name
  • Password - Personal access token created above
  • SCM private key - the private key portion of an ssh/gpg key added to Github

With that accomplished, create a new Project:

  • Name
  • Description
  • Organization
  • SCM Type - Git
  • SCM URL - https://www.github.com/user/repo
  • SCM Credential - Credential created above
  • SCM Branch/Tag/Commit - master (any changes I make will be merged into master once they are ready for production0

I need to make sure that the sync completes successfully and resolve any errors. Now I can create a new inventory which is sourced by the project:

  • Name
  • Description
  • Organization

Under the sources section, add a new source:

  • Name
  • Description
  • Source - Sourced from a project
  • Project - Project from above
  • Inventory file - path to inventory file in the project/repostory (e.g. inventory/prod.yml)

With that created, the sync button should kick off a job to import the inventory. I should now see them show up in the hosts tab of the inventory. Once I get the rest of my inventories imported, I will start creating some job templates to run my playbooks.