AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

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

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 referenceAnsible Windows administration walkthrough

See 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 PuffinHow to install Ansible in Ubuntu 24.10 Oracular OrioleHow to install Ansible in Rocky Linux 10How to install Ansible in Fedora 41How to install Ansible in Debian 13 TrixieAnsible Yum Errors: Fix Package Installation Failures (RHEL/CentOS)

Category: installation

Watch the video: Installing Ansible: A Step-by-Step Guide — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home