Bootstrap FreeKB - Ansible - Install Ansible on Linux using DNF
Ansible - Install Ansible on Linux using DNF

Updated:   |  Ansible articles

This article describes how to install Ansible but not Ansible Tower. Refer to Install Ansible Tower on Linux if you also want Tower.

The system that Ansible is installed on is known as the control node. Windows is not supported for the control node. Instead, Ansible must be installed on a Linux distribution.


Python

The control node must have Python version 2.7 or higher or Python version 3.5 or higher installed. The python --version command can be used to determine if Python is installed and the version that is installed. If Python is not installed, the installation of Ansible will also install Python.

~]$ python --version
Python 3.6.8

 


EPEL (Extra Packages for Enterprise Linux)

On a Red Hat distribution, Ansible is in the EPEL(Extra Packages for Enterprise Linux) repository, thus epel-release must be installed.

dnf install epel-release

 

Or like this (On Red Hat 7).

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

Or like this (on Red Hat 8).

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

 


Install

Before installing Ansible using dnf, the dnf list installed command can be used to determine if Ansible is already installed.

dnf list installed

 

If Ansible is already installed, something like this should be included in the output.

Installed Packages                      installed
ansible.noarch         2.4.2.0-2.el7    epel

 

The dnf list available command can be used to show the latest stable version of Ansible in the EPEL repository.

dnf list available | grep -i ansible

 

Something like this should be returned.

ansible.noarch   2.9.18-1.el7   epel

 

The dnf install ansible command can be used to install the latest stable version of Ansible in the EPEL repository.

dnf install ansible

 

If the install was successful, the /etc/ansible directory should contain the following.

-rw-r--r--. 1 root root 19179 Jan 29  2018 ansible.cfg
-rw-r--r--. 1 root root  1016 Jan 29  2018 hosts
drwxr-xr-x. 2 root root     6 Jan 29  2018 roles

 

The dnf info command should return the following.

Installed Packages
Name        : ansible
Arch        : noarch
Version     : 2.4.2.0
Release     : 2.el7
Size        : 38 M
Repo        : installed
From repo   : extras
Summary     : SSH-based configuration management, deployment, and task execution system
URL         : http://ansible.com
License     : GPLv3+
Description :
            : Ansible is a radically simple model-driven configuration management,
            : multi-node deployment, and remote task execution system. Ansible works
            : over SSH and does not require any software or daemons to be installed
            : on remote nodes. Extension modules can be written in any language and
            : are transferred to managed machines automatically.

 

Additionally, the ansible --version command should return output, like this.

ansible --version
. . .
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b5bfcd in the box below so that we can be sure you are a human.