Bootstrap FreeKB - Ansible - Resolve "The Python 2 bindings for rpm are needed for this module"
Ansible - Resolve "The Python 2 bindings for rpm are needed for this module"

Updated:   |  Ansible articles

Let's say something like this is being returned.

fatal: [ec2-23-22-195-223.compute-1.amazonaws.com]: FAILED! => {"changed": false, "msg": "The Python 2 bindings for rpm are needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.. The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead."}

 

I ran into this problem when attempting to install a package on Amazon Web Services (AWS) EC2 instances running the Amazon Linux Operating System using the yum module.

---
- hosts: aws
  tasks:
  - name: install git
    package:
      name: git
      state: latest
...

 

I couldn't use dnf since the Amazon Linux Operating System does not use dnf.

[ec2-user@ip-172-31-80-56 ~]$ which dnf
/usr/bin/which: no dnf in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin)

 

One option is to set /usr/bin/python2 as the Python interpreter.

---
- hosts: aws
  tasks:
  - name: install git
    package:
      name: git
      state: latest
    vars:
      ansible_python_interpreter: /usr/bin/python2
...

 




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 bae3cd in the box below so that we can be sure you are a human.