Ansible: “python2 yum module is needed for this module”

I am currently toying around with GlusterFS and I am using Ansible to deploy and configure my server.

Using the yum module, I wanted to install the Gluster server package like so:

- name: Install glusterfs-server package
  yum:
    name: glusterfs-server
    state: latest

But when executing the playbook, I received the following error on executing this module:

simon@boxen:~/git/simon-ansible$ ansible-playbook install_gluster.yml 

PLAY [Configure instance(s)]
[..]

TASK [gluster_role : Install gluster package] ******************************************************************************************************************
fatal: [10.140.10.31]: FAILED! => {"changed": false, "failed": true, "msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this  module"}
fatal: [10.140.10.30]: FAILED! => {"changed": false, "failed": true, "msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this  module"}
	to retry, use: --limit @/home/simon/git/simon-ansible/install_gluster.retry
[..]

So I found out that there are multiple possibilities why this error can occur:

  • Make sure the system you are provisioning is a RPM-based system. For example, executing the yum module on a Debian host will result in this error. Better use the apt module or the package module for generic package installation.
  • Is the yum package installed? Since I was using Fedora 26, yum was not installed by default (dnf is the new default package manager).
    Make sure you install the old yum package manager as well when using this Ansible module: dnf install yum.

In my case, after installing the yum package via dnf, I was able to use my playbook without any errors. By the way, if you are also using Ansible with Gluster, the gluster_volume module is pretty neat.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab