Unable to install using yum module: Request to provide help

Unable to run with yum module to install packages.

Below is the error message:

fatal: [sdtarget01p]: FAILED! => changed=false
module_stderr: |-
Shared connection to sdtarget01p.int.example.com closed.
module_stdout: |-
Traceback (most recent call last):
File “/home/aux502550/.ansible/tmp/ansible-tmp-1720531139.05-1803-207126550725931/AnsiballZ_yum.py”, line 102, in
_ansiballz_main()
File “/home/aux502550/.ansible/tmp/ansible-tmp-1720531139.05-1803-207126550725931/AnsiballZ_yum.py”, line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/home/aux502550/.ansible/tmp/ansible-tmp-1720531139.05-1803-207126550725931/AnsiballZ_yum.py”, line 40, in invoke_module
runpy.run_module(mod_name=‘ansible.modules.core.packaging.os.yum’, init_globals=None, run_name=‘main’, alter_sys=True)
File “/usr/lib64/python3.6/runpy.py”, line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File “/usr/lib64/python3.6/runpy.py”, line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File “/usr/lib64/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/tmp/ansible_yum_payload_1xqy_pbd/ansible_yum_payload.zip/ansible/modules/core/packaging/os/yum.py”, line 25, in
ModuleNotFoundError: No module named ‘yum’
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1

1 Like

Hello,

What OS are you running a playbook against? what ansible version ? can you share the playbook?

1 Like

Ansible can’t find yum … can you do it manually?

Echo what @iyami5 asks as well …

1 Like

Target Node is RHEL 8.9
Control Node is RHEL 7.9

ansible --version
ansible 2.9.10
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Nov 13 2023, 01:37:03) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)]

Playbook:

  • name: Install list of MySQL 8.2.O Commercial packages - List of packages defined in the default main.yml
    ansible.builtin.yum:
    name:
    • “{{ mysqlpackages }}”
      state: “present”

try using the dnf module instead.

1 Like

With dnf as well, I see the same error.

atal: [sdtarget01p]: FAILED! => changed=false
module_stderr: |-
Shared connection to sdtarget01p.int.example
.com closed.
module_stdout: |-
Traceback (most recent call last):
File “/home/asadmin/.ansible/tmp/ansible-tmp-1720540285.17-17206-38800975450038/AnsiballZ_dnf.py”, line 102, in
_ansiballz_main()
File “/home/asadmin/.ansible/tmp/ansible-tmp-1720540285.17-17206-38800975450038/AnsiballZ_dnf.py”, line 94, in ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/home/asadmin/.ansible/tmp/ansible-tmp-1720540285.17-17206-38800975450038/AnsiballZ_dnf.py”, line 40, in invoke_module
runpy.run_module(mod_name=‘ansible.modules.extras.packaging.os.dnf’, init_globals=None, run_name=‘main’, alter_sys=True)
File “/usr/lib64/python3.6/runpy.py”, line 205, in run_module
return run_module_code(code, init_globals, run_name, mod_spec)
File “/usr/lib64/python3.6/runpy.py”, line 96, in run_module_code
mod_name, mod_spec, pkg_name, script_name)
File “/usr/lib64/python3.6/runpy.py”, line 85, in run_code
exec(code, run_globals)
File "/tmp/ansible_ansible.builtin.dnf_payload_aa17bwb
/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/extras/packaging/os/dnf.py", line 436, in
File "/tmp/ansible_ansible.builtin.dnf_payload_aa17bwb
/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/extras/packaging/os/dnf.py", line 430, in main
File "/tmp/ansible_ansible.builtin.dnf_payload_aa17bwb
/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/extras/packaging/os/dnf.py", line 266, in ensure
File "/tmp/ansible_ansible.builtin.dnf_payload_aa17bwb
/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/extras/packaging/os/dnf.py", line 238, in _parse_spec_group_file
AttributeError: ‘list’ object has no attribute ‘endswith’
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1

yes, I can install manually.

I wonder if its the difference between python versions in your controller and node.

Can you use a supported version of Ansible? Red Hat’s offiical support of Ansible 2.9 ended December 31st, 2021.

Red Hat Ansible Engine Life Cycle - Red Hat Customer Portal

1 Like

Target node is Python 2.7.18
Control node is having Python 2.7.5

Not to mention that RHEL 7 just went EOL end of last month.

1 Like

Can you please share the latest stable tar.gz one to install on the RHEL 7.9 and to target on RHeL 8.9 ?

If you need to continue using the RHEL 7 server as a RHEL 7 Ansible control node, I would suggest yum remove ansible; yum install python3-pip; pip3 install ansible, and that will get you the latest version of Ansible for python 3.6.

However, I think it would be more prudent to build a new control node on RHEL 8 or 9 and eventually retire the RHEL 7 node, or perform a leapp in-place upgrade on the RHEL 7 control node. Whichever is easier.

1 Like

That’s not the same error.

First try running against one package specifically listed instead of using a list/variable. If that works, then you know it is something wrong with your list.

You also might need to have become: true, as that is usually needed for yum/dnf installs.