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.
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.
yum 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
Before installing Ansible, the dnf list installed or yum 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 ansible.noarch 2.9.21-1.el7 @epel
The dnf list available or yum list available command can be used to show the latest stable version of Ansible in the EPEL repository.
dnf list available
Something like this should be returned.
Available Packages ansible.noarch 2.9.27-1.el7 epel
The dnf install or yum install 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 or yum info command should return something like this.
Installed Packages Name : ansible Arch : noarch Version : 126.96.36.199 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 188.8.131.52 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)]