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 -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 20, 2023, at 11:08 AM, Saillesh Satam <sailleshsa...@gmail.com> wrote: 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 --- - hosts: all become: true vars: ansible_become_pass: tasks: - name: install ntp yum: name: ntp state: present notify: run update - name: install vim yum: name: vim state: present - name: start ntp service service: name: ntp state: started enabled: true handlers: - name: run update yum: update_cache: yes -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9108c006-ae4e-4e0b-948b-98fcd1d47436n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/9108c006-ae4e-4e0b-948b-98fcd1d47436n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/EE7D0A7D-242C-4DD0-BB97-681B01C6CEBF%40nist.gov.