In this guide we demonstrate how to install Ansible on AlmaLinux 9.2 using PIP. Please note that this procedure may or may not work for other versions of AlmaLinux. Let’s dive in…
Ansible is a suite of software automation tools owned by Red Hat that enables infrastructure as code. It is open-source and includes software provisioning, configuration management, and application deployment functionality. Ansible can manage IT infrastructure environments from a centralized location using the popular SSH and WinRM protocols. We will now demonstrate how to install Ansible on AlmaLinux 9.2 using PIP in 5 easy steps.
How to Install Ansible on AlmaLinux 9.2 using PIP
To follow this guide, you will need the following:
- A LinuxAlma 9.2 server installation.
- A non-root user with sudo privileges.
- To add a a non-root user with sudo privileges, issue the following commands (as root user):
useradd -m -d /home/ansibleuser -s /bin/bash -U ansibleuser passwd ansibleuser touch /etc/sudoers.d/ansibleuser echo 'ansibleuser ALL=(ALL:ALL) NOPASSWD:ALL'> /etc/sudoers.d/ansibleuser
Note: The last line (echo ‘ansibleuser…’) is optional and should only be run if you want to run sudo commands without getting prompted to enter a password. This is also a more insecure way to operate so run at your own discretion based on your environment.
Step 1 – Log in to AlmaLinux as a Non-Root Sudo User
Using Putty, SSH into AlmaLinux and log in as a non-root sudo user (i.e. ansibleuser).
Step 2 – Update the system
Ensure the system is up-to-date.
sudo dnf upgrade
Step 3 – Install Python Package Manager (PIP)
Install PIP as it will be utilized for installing Ansible.
sudo dnf install python3-pip
Step 4 – Install Ansible
sudo python3 -m pip install ansible
Note: You may (and should) elect to run this command without sudo. That is,
python3 -m pip install ansible. Not using sudo is the officially recommended way to install ansible. We use sudo for the simple reason that our Jenkins Ansible instances point at /usr/local/bin. Either way should work but if you are unsure, do not use sudo.
Step 5 – Validate Ansible Installation
Validate Ansible was properly installed.
Note the executable location (i.e. “/usr/local/bin/ansible”) and python version (i.e. “3.9.xx”) configuration. These settings are important for the Ansible deployment to work properly.
Well done! Ansible should now be ready to run playbooks on your AlmaLinux 9.2.