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.
- Install automation content navigator on a RHEL 9 control node.
- Log in to a container registry and download an execution environment.
- List what Linux, Windows and network managed hosts need.
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:
- Python 3.8 or later, required by the
ansible-corepackage that navigator depends on. - A valid Red Hat Ansible Automation Platform subscription, to install navigator from Red Hat's repositories. If your organisation uses Simple Content Access, you do not need to attach the subscription to the system.
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.0Execution 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 GBThis 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:
| Classroom | Home lab |
|---|---|
sudo dnf install ansible-navigator | ansible-core 2.14 from Rocky's repositories, and navigator from pip in its own virtual environment |
podman login and an execution environment image | No 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 environment | ansible.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.
- Python 3.8 or later for most modules. On RHEL 8 you can rely on
platform-python, or enable thepython38stream. - If SELinux is enabled,
python3-libselinuxfor file, copy and template tasks. - SSH access, and if you connect as a regular user, a way to become root, usually sudo.
- PowerShell 3.0 or later instead of Python.
- .NET Framework 4.0 or later.
- PowerShell remoting (WinRM) configured.
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:
- CLI over SSH
- XML over SSH
- an API over HTTP(S)
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:
- One RHEL 9 VM as the control node, called
workstation, and two to four RHEL 9 VMs as managed hosts, calledservera,serverband so on. A free Red Hat Developer subscription covers personal use. - Name resolution between them, through DNS or
/etc/hosts. - 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.
- Why do network modules usually run on the control node rather than on the device?
- Which of these must be installed on a RHEL managed host for most modules to work?
Takeaway
Install automation content navigator on a RHEL 9 control node. Use the chapter lab to check this on a real host.