This article describes how to install Ansible but not Ansible Tower. Refer to Install Ansible Tower on Linux if you also want Tower.
On a Red Hat distribution, the yum install ansible command can be used to install Ansible. However, be aware that this will setup Ansible to use Python version 2.7.5. Python 2.7 reached it's end of life support in January of 2020. For this reason, it is preferrable to use pip3 to install Ansible. The pip3 --version can be used to determine if pip3 is installed. If pip3 is installed, something like this should be displayed. If pip3 is not installed, refer to Installing PIP on Linux CentOS.
pip3 --version pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
The hash command caches the paths to commands, and if a command is relocated then bash will not pick it up unless that cache is cleared. Issue the following command to clear Ansible from the cache.
hash -d ansible
Use pip3 to install ansible.
pip3 install --user ansible
The pip3 show command can be used to ensure that Ansible was installed. In this example, Ansible version 2.9.12 is installed.
pip3 show ansible Name: ansible Version: 2.9.12 Summary: Radically simple IT automation Home-page: https://ansible.com/ Author: Ansible, Inc. Author-email: firstname.lastname@example.org License: GPLv3+ Location: /root/.local/lib/python3.6/site-packages Requires: jinja2, PyYAML, cryptography
Note that Ansible does not create a daemon, thus the systemctl command will not be used. Instead, Ansible uses SSH to manage remote systems (or a different networking protocol could be used). When installing Ansible using pip (or from source), the config file should return None. In this scenario, you can create the /etc/ansible directory (mkdir /etc/ansible) and the ansible.cfg file (touch /etc/ansible/ansible.cfg).
ansible 2.9.12 config file = None configured module search path = ['/home/jeremy.canfield/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.6/site-packages/ansible executable location = /usr/local/bin/ansible python version = 3.6.8 (default, Apr 2 2020, 13:34:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Notice in this example that the python version is 3.6. Let's say the python --version command returns version 2 of Python. This can be problematic. In this scneario, you'll most probably want to configure the python command to use version 3 of python.
python --version Python 2.7.5