Installing Ansible on Oracle Linux 7 for test and development use

There are a few alternative ways of installing Ansible on Linux, and the install guide for Ansible does a great job in explaining them all in detail.  There is a potentially easier way to get to a current Ansible version if you are using Oracle Linux 7, but it comes with a very important limitation. Let’s get that out of the way first.

You need to be aware that the RPM-based installation of Ansible as described in this blog post requires you to enable Oracle’s EPEL (“extra packages for Enterprise Linux”) repository. As per, the EPEL repository is listed under “Packages for Test and Development” at the bottom of the page and these come with the following warning: 

Note: The contents in the following repositories are for development purposes only. Oracle suggests these not be used in production. 

This is really important!

If you are ok with the limitation I just quoted from Oracle’s YUM server, please read on. If not, head back to the official Ansible documentation and use a different installation method instead. I only use Ansible in my own lab and therefore don’t mind.

Preparing the installation

Back to the topic of Ansible …

The way you install Ansible depends on how current your system is. Beginning in 2019 Oracle changed the YUM configuration, moving from a monolithic configuration file to a more granular approach. I blogged about it at the time, and you can find the change documented on Oracle’s YUM repository as well. This post assumes you have already made the transition to the new YUM configuration. If not, check the previous link for instructions. My vagrant box is based on Oracle Linux 7.9 so I should be ok.

Before you can install Ansible, you need to enable the EPEL repo.

[vagrant@ansible ~]$ sudo yum-config-manager --enable ol7_developer_EPEL
[vagrant@ansible ~]$ sudo yum repolist
Loaded plugins: ulninfo
repo id                   repo name                                                        status
ol7_UEKR6/x86_64          Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux     282
ol7_developer_EPEL/x86_64 Oracle Linux 7Server EPEL Packages for Development (x86_64)      37,236
ol7_latest/x86_64         Oracle Linux 7Server Latest (x86_64)                             22,263
repolist: 59,781

You may have to install oracle-epel-release-el7 first, if /etc/yum.repos.d/oracle-epel-ol7.repo doesn’t exist yet.

Be careful though: your changes might trigger a kernel upgrade as described in an earlier post of mine.

Installing Ansible

With the developer EPEL repository enabled, you finally have access to Ansible. Now before you rush and install Ansible, a word of caution: there are actually 2 versions of Ansible available:

  • ansible
  • ansible-python3

It’s not immediately obvious, but the latter is the version you want:

[vagrant@ansible ~]$ sudo yum info ansible-python3
Loaded plugins: ulninfo
Available Packages
Name        : ansible-python3
Arch        : noarch
Version     : 2.9.18
Release     : 1.el7
Size        : 16 M
Repo        : ol7_developer_EPEL/x86_64
Summary     : SSH-based configuration management, deployment, and task execution system
URL         :
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.
            : This package installs versions of ansible that execute on Python3.

Note the last line: this package installs the version based on Python 3. To avoid name clashes, the binaries have a suffix, as in ansible-3 or ansible-playbook-3. Once ansible-python3 is installed, you can see it’s working:

[vagrant@ansible ~]$ ansible-playbook-3 --version
ansible-playbook-3 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook-3
  python version = 3.6.8 (default, Mar  9 2021, 15:08:44) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)]
[vagrant@ansible ~]$ 

Happy testing!