# issue while runing script

**URL:** <https://forum.ansible.com/t/issue-while-runing-script/38248>\
**Category:** Ansible Project\
**Created:** [July 20, 2023, 3:08pm UTC](https://forum.ansible.com/t/issue-while-runing-script/38248 "2023-07-20T15:08:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saillesh\_Satam](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Saillesh\_Satam](https://forum.ansible.com/u/Saillesh_Satam)\
**Post date:** [July 20, 2023, 3:08pm UTC](https://forum.ansible.com/t/issue-while-runing-script/38248/1 "2023-07-20T15:08:22Z")

</div>

I am getting below error

FAILED! =\> {“changed”: false, “msg”: “The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.”}

Please help

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [July 24, 2023, 7:26pm UTC](https://forum.ansible.com/t/issue-while-runing-script/38248/2 "2023-07-24T19:26:00Z")

</div>

The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.

You need to install yum bindings for Python2 or dnf bindings for Python3 on the remote machine.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [July 24, 2023, 7:29pm UTC](https://forum.ansible.com/t/issue-while-runing-script/38248/3 "2023-07-24T19:29:48Z")

</div>

Use the ‘package’ module instead of ‘yum’. It will do the right thing on each OS. Also, pass all the packages in a single task.

- hosts: all  
become: true  
vars:  
ansible\_become\_pass:  
pkgs:

- vim

- ntp  
tasks:

- name: “install packages {{ pkgs }}”  
package:  
name: “{{ pkgs }}”  
state: present  
notify: “packages installed”

handlers:

- name: start and enable ntp  
service:  
name: ntp  
state: started  
enabled: true  
listen: “packages installed”

- name: update yum cache  
yum:  
update\_cache: yes  
listen: “packages installed”

Walter
