Installing Ansible: A Step-by-Step Guide
By Luca Berton · Published 2024-01-01 · Category: installation
Learn how to install Ansible on Linux, macOS, and Windows, and configure it for efficient IT automation with this step-by-step guide.

Installing Ansible: A Step-by-Step Guide
Ansible is a powerful open-source tool for IT automation, allowing you to manage configurations, deploy applications, and orchestrate complex workflows. This article provides a comprehensive guide to installing Ansible on various operating systems, ensuring you can get started with automating your IT infrastructure efficiently.
See also: How to Install Ansible on Ubuntu 23.10 Mantic Minotaur
Prerequisites
Before installing Ansible, ensure you have the following prerequisites: • A supported operating system (Linux, macOS, or Windows with WSL) • Python 3.6 or later (for some distributions, Python 2.7 is still supported but not recommended) • Access to an internet connection to download Ansible packages
Installing Ansible on Linux
Debian-based Systems (Ubuntu, Debian) Update Your Package Index:
sudo apt update
Install Ansible:
sudo apt install ansible -y
Verify the Installation:
ansible --version
Red Hat-based Systems (RHEL, CentOS, Fedora) Enable EPEL Repository (for CentOS):
sudo yum install epel-release -y
Install Ansible (for Fedora, RHEL):
sudo yum install ansible -y
Verify the Installation:
ansible --version
Arch-based Systems (Arch Linux, Manjaro) Install Ansible:
sudo pacman -S ansible
Verify the Installation:
ansible --version
See also: How to install Ansible in Fedora 40 — Ansible install
Installing Ansible on macOS
For macOS, Ansible can be installed using Homebrew. Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Ansible:
brew install ansible
Verify the Installation:
ansible --version
Installing Ansible on Windows
On Windows, Ansible can be installed using the Windows Subsystem for Linux (WSL). Enable WSL: • Open PowerShell as Administrator and run:
wsl --install
Install a Linux Distribution:
• After enabling WSL, install a Linux distribution from the Microsoft Store (e.g., Ubuntu).
Install Ansible in WSL:
• Open the installed Linux distribution and follow the installation steps for Debian-based systems mentioned above.
See also: How to install Ansible in Fedora 43 — Ansible install
Installing Ansible Using Pip
Alternatively, Ansible can be installed using Python's package manager, pip. This method works on any operating system with Python installed. Install pip (if not already installed):
sudo apt install python3-pip -y # Debian-based
sudo yum install python3-pip -y # Red Hat-based
Install Ansible Using pip:
pip3 install ansible
Verify the Installation:
ansible --version
Configuring Ansible
After installing Ansible, a few configuration steps will help you get started with automation:
Set Up the Inventory File:
• Create a file named hosts (or any preferred name) and list your managed nodes (hosts) in it.
[webservers]
server1.example.com
server2.example.com
[dbservers]
db1.example.com
db2.example.com
Create an Ansible Configuration File (optional):
• Create an ansible.cfg file in your project directory to customize Ansible's behavior.
[defaults]
inventory = ./hosts
remote_user = your_user
Test Your Setup:
• Use the ping module to test connectivity to your managed nodes.
ansible all -m ping
Conclusion
Installing Ansible is a straightforward process that can be accomplished on various operating systems using different methods. Whether you prefer using native package managers, Homebrew, or pip, Ansible's flexible installation options ensure you can set it up in your preferred environment. By following this guide, you can quickly get started with Ansible and begin automating your IT tasks, improving efficiency, consistency, and reliability across your infrastructure.
For more detailed information and advanced configurations, refer to the official Ansible documentation.
Related Articles
• Ansible inventory complete reference • Ansible Windows administration walkthroughSee also
• How to Install Ansible on Ubuntu 26.04 (Ubiquitous Unicorn) • How to Install Ansible on Ubuntu 25.10 (Questing Quokka) • How to install Ansible in Ubuntu 25.04 Plucky Puffin • How to install Ansible in Ubuntu 24.10 Oracular Oriole • How to install Ansible in Rocky Linux 10 • How to install Ansible in Fedora 41 • How to install Ansible in Debian 13 Trixie • Ansible Yum Errors: Fix Package Installation Failures (RHEL/CentOS)Category: installation
Watch the video: Installing Ansible: A Step-by-Step Guide — Video Tutorial