How to install Ansible
If you’re looking for how to install Ansible without the hassle of a Red Hat subscription, using pip
is the easiest way to get started!
Whether you’re using RHEL, CentOS, Fedora, or any other Linux distribution, this guide will walk you through the steps to install Ansible using Python’s package manager, pip
.
In this blog post, I’ll cover:
- What Ansible is and its key features.
- How to install Python3 and pip (if not already installed).
- How to install Ansible using pip.
- Verifying your Ansible installation.
Additionally, I’ve included a video tutorial that walks you through the installation process.
What is Ansible?
Ansible is an open-source IT automation engine that helps you automate cloud provisioning, configuration management, application deployment, and many other IT processes. It’s simple, agentless, and can be used across various platforms, making it a favorite tool in the DevOps space.
Some key features of Ansible:
- Agentless: One of Ansible’s standout features is agentless nature. Unlike some other tools, Ansible doesn’t require agents or additional software on the target hosts, simplifying the management process.
- Idempotent: Another crucial feature of Ansible is idempotency. This means that Ansible tasks can be run multiple times without causing unintended side effects, ensuring consistent and predictable results.
- Playbooks: Playbooks are at the heart of Ansible. They allow you to define and automate tasks in a specified order, providing a powerful way to automate complex operations.
- Module Ecosystem: Ansible offers a wide range of built-in modules for common tasks like package management, file operations, and service control. And for more specialized tasks, we can create our own modules.
Step-by-Step Guide to Installing Ansible Using pip
Install Python3 and pip
Before you can install Ansible, ensure that Python3 and pip
are installed on your system.
- For RHEL, CentOS, Fedora:
[root@ip-172-31-86-70 ec2-user]# sudo yum install python3 -y
[root@ip-172-31-86-70 ec2-user]# sudo yum install python3-pip -y
- For Ubuntu/Debian
[root@ip-172-31-77-71 ec2-user]# sudo apt update
[root@ip-172-31-77-71 ec2-user]# sudo apt install python3 python3-pip -y
To verify Python and pip installation, run:
[root@ip-172-31-86-70 ec2-user]# python3 --version
[root@ip-172-31-86-70 ec2-user]# pip3 --version
Install Ansible Using pip
After installing Python3 and pip, install Ansible using pip.
[root@ip-172-31-86-70 ec2-user]# pip3 install ansible
This will download and install the latest version of Ansible from the Python Package Index (PyPI).
If we are using pip to install ansible most of the time it places all the ansible packages files under /usr/local/bin and if /usr/local/bin is not your default path then we need to add these packages under /usr/bin or add /usr/local/bin in under default
[root@ip-172-31-86-70 ec2-user]# export PATH=$PATH:/usr/local/bin
Verify the Ansible Installation
After installing Ansible, verify the installation by checking the version.
[root@ip-172-31-86-70 ec2-user]# ansible --version
If the installation was successful, you should see the Ansible version and some additional details.
Conclusion
Using pip to install Ansible on Linux is an efficient and straightforward way to get Ansible up and running. With just a few commands, you’ll be ready to start automating your tasks and workflows.
For more ansible related information check out my blogs on Ansible.
For more Ansible documentation check out official documentation.