How to install Ansible

How to install Ansible

1. Purpose

This article provides a focused, crystal-clear procedure strictly for installing Ansible on the control node and validating the installation. It excludes inventories, playbooks, and advanced configuration, making it suitable for baseline OS provisioning and enterprise standards.

2. Scope

Included

  1. Control Node Requirements

  2. OS-Specific installation steps

  3. Version validation

  4. Upgrade and removal

  5. Common installation issues

3. Supported Platforms

  1. Ubuntu 20.04/22.04/24.04

  2. Debian 11/12

  3. RHEL 8/9

  4. Rocky Linux 8/9

4. Prerequisites

  1. Root or sudo privileges

  2. Python 3.8 or higher

  3. Outbound internet access to OS repositories

  4. Verify prerequisites:

python3 --version sudo whoami

5. Installation Procedures

5.1 Ubuntu / Debian

sudo apt update sudo apt install -y software-properties-common sudo apt install -y ansible

Check version:

ansible --version

5.2 RHEL / Rocky

sudo dnf install -y epel-release sudo dnf install -y ansible-core

Optional full package:

sudo dnf install -y ansible

Verify:

ansible --version

  1. Version and Environment Validation

ansible --version which ansible python3 -c "import ansible; print(ansible.__version__)"

Expected:

  • Ansible binary available

  • Python interpreter detected

  • No module imports errors


  1. Upgrade Procedure

Ubuntu / Debian

sudo apt update sudo apt upgrade -y ansible

RHEL-based

sudo dnf upgrade -y ansible-core

  1. Removal Procedure

Ubuntu / Debian

sudo apt remove -y ansible sudo apt autoremove -y

RHEL-based

sudo dnf remove -y ansible ansible-core