dnf module error for python 3.8.6 version

Latest response

We have a Linux OS patching playbook written and working smoothly for RHEL 7/8 servers but recently built RHEL 8 servers are giving issue for which python default version is 3.8.3 and it's working very well with python version 3.6.8. It's very strange it's not working on python latest version but we are not positive on downgrading the version. As a workaround, we had used alternatives python to use 3.6.8 but we are looking for permanent solution. we are using ansible version 2.10.6 and controller node is RHEL 8 with latest kernel version which is released this month.

We have installed the package python-dnf package as well as dnf pip module is installed in both controller node and remote server but that didn't fix the issue. playbook works perfectly with python 3.6.8 version.

Sample output

 # python
Python 3.8.0 (default, Mar  9 2020, 18:02:46) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>

# python
Python 3.6.8 (default, Dec  5 2019, 15:45:45) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnf
>>> 

Responses

Yes, I'm aware of this problem statement here. Chaitanya is my co-worker. I see a matching issue has been recorded in this thread https://github.com/ansible/ansible/issues/71668

Let's see what the community members have to say about this.

Btw, they are using community version of Ansible. Hence, unable to raise a support ticket directly.

Hello Tess,

Could you help us here? I'd highly appreciate if you could pull someone from Red Hat technical team of Ansible to look into this. We are not expecting an immediate turn around though, as we are aware of getting help in this forum. Any help is appreciated.

Thanks!

Hi Chaitanya and Sadashiva,

The main problem is that you seem to be using the Ansible 2.10 (community supported) edition and not the officially supported
version 2.9 that Red Hat ships with RHEL 7 and 8. This makes it difficult to get support from Red Hat. And I can't find a package
'python-dnf' in the Red Hat repositories. I'm gonna send a message to Tess, to make her aware of your request to find someone
within the Red Hat organization who can chime in and have a look. Unfortunately I can't do much more for you at the moment. :)

$ sudo dnf list python-dnf
Error: No matching Packages to list

Regards,
Christian

Thanks Christian. Yes, we are aware of the community edition of Ansible being used here.

You're welcome, Sadashiva ! Guess what ? Teresa responded "as fast as lightning". :)
"I've reached out to a few Red Hatters and will see if I can get someone to respond!"
One question remains for me ... Why don't you just use the official Red Hat version ?

Regards,
Christian

Thanks for the update Christian. Yes, it is client decision and they are also aware of the limitations with community edition. Hoping that someone from Red Hat Ansible team would provide some direction in getting this fixed.

Thanks so much Christian and Sadashiva for looking into it and trying to help me on this. We already have below packages installed one the control node but it didn't help.

# rpm -qa| grep -i python3-dnf
python3-dnf-plugin-spacewalk-2.8.5-11.module+el8.1.0+3455+3ddf2832.noarch
python3-dnf-4.4.2-11.el8.noarch
python3-dnf-plugin-post-transaction-actions-4.0.18-4.el8.noarch
python3-dnf-plugins-core-4.0.18-4.el8.noarch
python3-dnf-plugin-versionlock-4.0.18-4.el8.noarch
# ansible --version
ansible 2.10.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
We have installed the dnf module as well 
pip3 list dnf | grep -i dnf
dnf               0.0.1

You're welcome, Chaitanya ! I see you meant python3-dnf ... yes, this package exists of course. :)

Regards,
Christian

Hi there from the Ansible team! I discussed this with my colleagues and the recommendation would be if you are a RHEL customer, you can open a RHEL support ticket for python configuration and get the best effort support going that route.

Thanks Jamie for the recommendation. Lets see how it goes.

Thanks Jamie and Sadashiva for trying to help on this!

Thanks a lot for your efforts and for offering this possibility, Jamie ! I wish you good luck, Chaitanya. :)

Regards,
Christian