Reader small image

You're reading from  Practical Ansible - Second Edition

Product typeBook
Published inSep 2023
PublisherPackt
ISBN-139781805129974
Edition2nd Edition
Right arrow
Authors (3):
James Freeman
James Freeman
author image
James Freeman

James Freeman is an accomplished IT professional with over 25 years' experience in the technology industry. He has more than a decade of first-hand experience in solving real-world enterprise problems in production environments using Ansible, open source, and AWS. As part of this work, he frequently introduces Ansible as a new technology to businesses and CTOs for the first time. In addition, he has co-authored five books and one video training course on Ansible, facilitated bespoke Ansible workshops and training sessions, and presented at both international conferences and meetups on Ansible.
Read more about James Freeman

Fabio Alessandro Locati
Fabio Alessandro Locati
author image
Fabio Alessandro Locati

Fabio Alessandro Locati – commonly known as Fale – is an EMEA associate principal solutions architect at Red Hat, a public speaker, an author, and an open source contributor. His primary areas of expertise are Linux, automation, security, and cloud technologies. Fale has more than 15 years of working experience in IT, with many of them spent consulting for various organizations, including dozens of Fortune 500 companies. Fale has written Learning Ansible 2.7, Learning Ansible 2, and OpenStack Cloud Security, and has been part of the review process of multiple books.
Read more about Fabio Alessandro Locati

Daniel Oh
Daniel Oh
author image
Daniel Oh

Daniel Oh is a principal technical marketing manager at Red Hat. He provides runtimes, frameworks, fast data access, and high-performance messaging in flexible, easy-to-use, cost-effective, open, and collaborative ways. He's also a CNCF ambassador and DevOps Institute ambassador who evangelizes how to design and develop cloud-native serverless microservices and deploy them to multi/hybrid cloud-native platforms based on CNCF projects. Daniel loves to share his developer experiences with DevOps folks in terms of how to evolve traditional microservices to cloud-native, event-driven, and serverless applications via technical workshops, brown bag sessions, hackathons, and hands-on labs across regions at many international conferences.
Read more about Daniel Oh

View More author details
Right arrow

Getting Started with Ansible Automation Controller

Ansible is very powerful, but it does require the user to use the CLI. In some situations, this is not the best option, such as in cases where you need to trigger an Ansible job from another job (where APIs would be better) or in cases where the person that should trigger a job should only be able to trigger that specific job. For these cases, AWX and Ansible Automation Controller are the best options to use.

The only differences between AWX and Ansible Automation Controller are that AWX is the upstream and open source version, while Ansible Automation Controller is the Red Hat and downstream component that is officially supported as part of the Ansible Automation Platform but for a price, and also the delivery method. AWX is available as a Kubernetes Operator that can run on any Kubernetes cluster, while Ansible Automation Controller is either installable via the Kubernetes Operator on a Red Hat OpenShift installation or on an...

Technical requirements

Although there are a couple of ways to install AWX, we are going to use the suggested AWX installation, which is the operator-based one. For this reason, you will need to have a Kubernetes cluster available.

The easiest way to have one on your machine is to use minikube.

On Linux machines, it is enough to download it from GitHub (https://github.com/kubernetes/minikube) and run it with the following command:

minikube start --cpus=4 --memory=6g --addons=ingress

In the next section, we will use the kubectl command. To have it available using minikube, you will need to execute the following:

alias kubectl="minikube kubectl --"

On other operating systems, the process might be different, and I suggest checking minikube’s official documentation (https://minikube.sigs.k8s.io/docs/start/) to see which installation method better suits your platform and needs.

Although we will give specific examples of hostnames in this chapter, you are...

Installing AWX

Before we discuss AWX, it is best if you have it installed on your machine so that you can follow the explanations and immediately start to use AWX.

The easiest way to install AWX Operator is using Kustomize.

We will need to create a file called kustomization.yaml with the following content:

---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - github.com/ansible/awx-operator/config/default?ref=2.3.0
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.3.0
namespace: awx

Note that version 2.3.0 is the most current at the time of writing. To find out which is the latest available version, go to https://github.com/ansible/awx-operator/releases.

Now that we have the kustomization file ready, we can apply it with the following command:

kubectl apply -k .

Once the previous command has finished, we shall be able to see the AWX Operator controller manager pod running:

$ kubectl...

Running your first playbook from AWX

As in Ansible, in AWX, the goal is running an Ansible playbook. Each playbook that is run is called a job. Since AWX gives you more flexibility and automation than Ansible, it requires a little bit more configuration before you can run your first job, so let’s dive into it, starting with creating an AWX project.

Creating an AWX project

AWX uses the term project to identify a repository of Ansible playbooks. AWX projects support the placement of playbooks in all major Source Control Management (SCM) systems, such as Git and SVN, but also support playbooks on the filesystem or playbooks provided by Red Hat Insights. To create a project, follow these steps:

  1. First of all, you need to go to Projects from the left-hand side menu bar, then click the Add button in the top-left section of the screen. This will open a window, similar to the following:
Figure 13.1 – The Create New Project window

Figure 13.1 – The Create New Project window

...

Controlling access to AWX

In my opinion, one of the biggest advantages of AWX compared to Ansible is the fact that AWX allows multiple users to connect and control/perform actions. This allows a company to have a single AWX installation for different teams, a whole organization, or even multiple organizations.

A role-based access control (RBAC) system is in place to manage the users’ permissions.

Both AWX and Ansible Automation Controller can link to central directories, such as Lightweight Directory Access Protocol (LDAP) and Azure Active Directory – however, we can also create user accounts locally on the AWX server itself. Let’s start by creating our first user account locally!

Creating a user

One of the big advantages of AWX is the ability to manage multiple users. This allows us to create a user in AWX for each person that is using the AWX system so that we can ensure they are only granted the permissions that they need. Also, by using individual...

Summary

AWX and Ansible Automation Controller are powerful, complementary tools that powerfully support the use of Ansible in an enterprise or team-based environment. They can help secure credentials that you would otherwise have to distribute widely, audit the history of playbook runs, and enforce the version control of playbooks. The web-based user interface of these tools creates a low barrier for entry for end users, meaning playbook runs can easily be delegated to teams who otherwise have little knowledge of Ansible (so long as suitable escalation paths are put in place should problems arise). In short, when implementing Ansible in a corporate setting, its usage should not be considered complete without the addition of Ansible Automation Controller or AWX.

In this chapter, you learned how to install AWX on your Linux host, as well as the necessary steps to run your very first playbook from AWX. You also learned about RBAC in AWX and how this can support large, multi-user environments...

Questions

Answer the following questions to test your knowledge of this chapter:

  1. Which objects can you create in Ansible Automation Controller?
    1. Users
    2. Jobs
    3. Job templates
    4. Modules
    5. Projects
  2. True or false? AWX is the upstream version of Red Hat Ansible Automation Controller:
    1. True
    2. False
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Practical Ansible - Second Edition
Published in: Sep 2023Publisher: PacktISBN-13: 9781805129974
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (3)

author image
James Freeman

James Freeman is an accomplished IT professional with over 25 years' experience in the technology industry. He has more than a decade of first-hand experience in solving real-world enterprise problems in production environments using Ansible, open source, and AWS. As part of this work, he frequently introduces Ansible as a new technology to businesses and CTOs for the first time. In addition, he has co-authored five books and one video training course on Ansible, facilitated bespoke Ansible workshops and training sessions, and presented at both international conferences and meetups on Ansible.
Read more about James Freeman

author image
Fabio Alessandro Locati

Fabio Alessandro Locati – commonly known as Fale – is an EMEA associate principal solutions architect at Red Hat, a public speaker, an author, and an open source contributor. His primary areas of expertise are Linux, automation, security, and cloud technologies. Fale has more than 15 years of working experience in IT, with many of them spent consulting for various organizations, including dozens of Fortune 500 companies. Fale has written Learning Ansible 2.7, Learning Ansible 2, and OpenStack Cloud Security, and has been part of the review process of multiple books.
Read more about Fabio Alessandro Locati

author image
Daniel Oh

Daniel Oh is a principal technical marketing manager at Red Hat. He provides runtimes, frameworks, fast data access, and high-performance messaging in flexible, easy-to-use, cost-effective, open, and collaborative ways. He's also a CNCF ambassador and DevOps Institute ambassador who evangelizes how to design and develop cloud-native serverless microservices and deploy them to multi/hybrid cloud-native platforms based on CNCF projects. Daniel loves to share his developer experiences with DevOps folks in terms of how to evolve traditional microservices to cloud-native, event-driven, and serverless applications via technical workshops, brown bag sessions, hackathons, and hands-on labs across regions at many international conferences.
Read more about Daniel Oh