Chapter 2: Introducing Ansible

Preparing the control node and managed hosts

Only the control node needs Ansible software. Managed hosts just need to be reachable and to meet a few small requirements, which differ for Linux, Windows and network devices.

Preparing the control node

To run playbooks you install automation content navigator (ansible-navigator) on the control node and download an execution environment for it to use. Before you start, the control node needs:

Here is how the pieces fit together at run time:

How ansible-navigator runs a playbook: ansible-navigator starts the execution environment with Podman, mounts your project into it, and the container connects to the managed hosts.

Installation, step by step

On a registered system, enable the Automation Platform repository. Classroom machines are already configured.

[user@controlnode ~]$ sudo subscription-manager repos \
> --enable ansible-automation-platform-2.2-for-rhel-9-x86_64-rpms
[user@controlnode ~]$ sudo dnf install ansible-navigator
[user@controlnode ~]$ ansible-navigator --version
ansible-navigator 2.1.0

Execution environment images come from a registry, such as registry.redhat.io or a private automation hub.

[user@controlnode ~]$ podman login registry.redhat.io
Username: your-registry-username
Password: your-registry-password
Login Succeeded!

Pull the image you plan to use. Navigator can also pull its default image automatically the first time it runs.

[user@controlnode ~]$ podman pull \
> registry.redhat.io/ansible-automation-platform-22/ee-supported-rhel8:latest
[user@controlnode ~]$ ansible-navigator images
  Image                 Tag      Execution environment   Created       Size
0│ee-supported-rhel8    latest   True                    5 weeks ago   1.32 GB

This opens navigator's interactive mode. Press Esc to leave it.

Rocky Linux has no ansible-navigator RPM and no access to Red Hat's registry, so section 1.6 installs the pieces another way:

ClassroomHome lab
sudo dnf install ansible-navigatoransible-core 2.14 from Rocky's repositories, and navigator from pip in its own virtual environment
podman login and an execution environment imageNo login and no image: navigator is configured with the execution environment switched off, and runs workstation's own ansible-core
Collections come inside the execution environmentansible.posix and community.general are installed in /usr/share/ansible/collections

Every ansible-navigator command in this guide works the same either way. To see the container workflow once, run ansible-navigator images --ee true: it pulls the free community image.

Preparing managed hosts

Managed hosts need no agent. The control node reaches them with a standard protocol and makes sure they are in the specified state. What they do need depends on the platform.

The course uses Linux hosts only; see the Ansible Windows guides for more.

Most devices cannot run Python, so network modules run on the control node and talk to the device through:

Supported platforms include Cisco IOS, IOS XR and NX-OS, Juniper Junos, Arista EOS and VyOS.

Building your own practice lab

If you do not have the Red Hat classroom, you can recreate the essentials with virtual machines:

  1. One RHEL 9 VM as the control node, called workstation, and two to four RHEL 9 VMs as managed hosts, called servera, serverb and so on. A free Red Hat Developer subscription covers personal use.
  2. Name resolution between them, through DNS or /etc/hosts.
  3. A user on each managed host that the control node can SSH to with a key and that can use sudo. You will set this up properly in chapter 3.

Takeaway

Install automation content navigator on a RHEL 9 control node. Use the chapter lab to check this on a real host.