ClickCease

Today there are 3 variants of Ansible available:

  • From the upstream community
  • As part of Red Hat Enterprise Linux, with limited support
  • With the fully supported Red Hat Ansible Automation Platform product

We will be exploring the Red Hat Ansible Automation Platform in this article. However, irrespective of which variant of Ansible you use, the fundamentals remain the same and the way of writing Playbooks (your code) remains the same as well.

Ansible Automation Platform uses a new tool to run Ansible playbooks, this tool is known as the automation content navigator (ansible-navigator). This tool replaces earlier commands such as ansible-playbook, ansible-config, ansible-inventory, etc. Ansible Navigator uses automation execution environments to run Ansible Playbooks, these execution environments are container images that contain Ansible core, Ansible Content Collections, Python libraries, and other required files. So, instead of installing Ansible core directly on your virtual machine, you spawn Ansible containers that run the Ansible Playbook and automatically terminate once the Ansible Playbook has completed executing. The advantage here is that the Ansible environments can remain the same across different software lifecycles of the organization such as Development or Production since container images are immutable in nature. Refer to the below diagram to understand how the execution happens:

Virtual Machine spawns an Ansible container which runs the Ansible playbook on the remote hosts.

To perform this, we will have to install Ansible navigator on a Linux virtual machine. Here we are using a RHEL9 virtual machine since Ansible navigator requires Python version 3.8 minimum.

yum install python3-pip -y
pip3.9 install 'ansible-navigator[ansible-core]'

Once Ansible navigator is installed, the next step would be to get the container image. Even though community images are available, we should be able to download the image from the Red Hat registry.

podman login registry.redhat.io
podman pull registry.redhat.io/ansible-automation-platform-22/ee-supported-rhel8:latest
ansible-navigator images

The last command above should show you the image that you downloaded using Podman. Also, I am not covering Ansible inventory files here, it is my assumption that you have used Ansible core in the past and are aware of the basics.
Since Ansible uses SSH for creating connections, we need to allow our container images to use. Assuming that your key is already generated, you can start the SSH agent to ensure that the key can be used by containers which are spun up by Podman.

eval "$(ssh-agent -s)"

Finally, you can run your playbooks using the below command:

ansible-navigator run playbook.yml -m stdout -i inventory

That is how you can use the new Ansible navigator technology to run your Ansible Playbooks. There are other important things that you should know about Ansible Navigator such as managing multiple container images and creating custom images. We will discuss those in the upcoming articles.