This content originally appeared on DEV Community and was authored by M. Oly Mahmud
In this guide, we’ll walk through the different ways to install Ansible and get it running on your system. By the end, you’ll be able to execute Ansible commands globally from your terminal.
What is Ansible?
Ansible is an open-source automation engine that helps manage systems, deploy applications, and orchestrate workflows. Unlike many other configuration management tools, Ansible doesn’t require installing agents on managed nodes. It only needs SSH access and Python on the target machine, which keeps things lightweight and secure.
Installation Options
There are several ways to install Ansible:
-
Package Manager – Install via
apt
(Debian/Ubuntu),dnf
oryum
(RHEL/CentOS/Fedora). -
Pip (Python package manager) – Install via
pip3
, which gives you more control over the version. - From Source – Clone the official Ansible GitHub repository.
In this article, we’ll focus on the pip3 installation method since it allows us to install a specific version and ensures portability across environments.
Step 1: Install Python and Pip
Ansible requires Python 3. Most modern Linux distributions come with Python pre-installed. If not, install Python and pip3:
sudo apt update -y
sudo apt install -y python3 python3-pip
You can verify the installation with:
python3 --version
pip3 --version
Step 2: Install Ansible via pip3
To install the latest version of Ansible globally, run:
sudo pip3 install ansible
If you want to install a specific version (for example, Ansible 4.9.0), use:
sudo pip3 install ansible==4.9.0 --prefix=/usr/local
The --prefix=/usr/local
flag ensures that the binary goes into /usr/local/bin
, which is accessible by all users on the system.
Step 3: Verify Installation
After installation, check whether Ansible is installed correctly:
ansible --version
You should see output similar to:
ansible [core 2.11.x]
config file = None
ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.x.x
Step 4: Add Ansible to PATH (if needed)
If the ansible
command isn’t found, add /usr/local/bin
to your PATH. Create a file under /etc/profile.d/
:
echo 'export PATH=$PATH:/usr/local/bin' | sudo tee /etc/profile.d/ansible.sh
sudo chmod +x /etc/profile.d/ansible.sh
Reload the environment:
source /etc/profile
Now Ansible will be available to all users.
Step 5: Test Ansible with a Ping Command
To make sure Ansible can talk to your servers, create an inventory file:
[servers]
192.168.1.10
192.168.1.11
Then run:
ansible -i inventory servers -m ping
If everything is set up correctly, you’ll see a “pong” response from each server.
Conclusion
So, we've successfully installed Ansible.
This content originally appeared on DEV Community and was authored by M. Oly Mahmud

M. Oly Mahmud | Sciencx (2025-10-03T14:42:03+00:00) Day-8: Install Ansible | 100 Days of DevOps. Retrieved from https://www.scien.cx/2025/10/03/day-8-install-ansible-100-days-of-devops/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.