Installing Ansible on Linux#
Installing Ansible on Linux is a simple process and can be done in different ways. The most common ways to install Ansible on Linux are using the package manager or using pip into a virtual environment.
Installing Ansible using package manager#
Installing Ansible using package manager is the easiest way to install Ansible on Linux. The package manager will take care of all the dependencies and install the required packages.
For example, to install Ansible on Ubuntu, you can use the following command:
sudo apt-get update
sudo apt-get install ansible
This will install Ansible on your system along with all the required dependencies.
sudo dnf install ansible
Installing Ansible using pip#
If you prefer to install Ansible using pip, you can do so by running the following command:
pip install ansible
This will install Ansible on your system along with all the required dependencies.
Note
It is recommended to install Ansible in a virtual environment to avoid conflicts with other Python packages.
python3 -m venv ansible-env
source ansible-env/bin/activate
pip install ansible
Ansible can also be installed under the user’s home directory using the --user
option.
pip install --user ansible
Verifying the installation#
Once you have installed Ansible, you can verify the installation by running the following command:
ansible --version
This will display the version of Ansible installed on your system and other relevant information like the Python version and the location of the configuration file.