# Centos7, Python3, Yum, DNF & builtin.command OH MY!

**URL:** <https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153>\
**Category:** Ansible Project\
**Created:** [September 28, 2022, 5:04pm UTC](https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153 "2022-09-28T17:04:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmartin](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@dmartin](https://forum.ansible.com/u/dmartin)\
**Post date:** [September 28, 2022, 5:04pm UTC](https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153/1 "2022-09-28T17:04:39Z")

</div>

Okay! So, we have a bunch of proprietary software that we have to run on Centos 7. We’ve been using python3 for years. I’m trying to install an RPM with ansible yum module and it fails because python3. It suggests DNF, but hey, Centos7 doesn’t have DNF. Okay, I’ll just use builtin.command. Builtin.command says "Hey, you should use ‘yum’! If you don’t want this warning set warn: false. Docs say the ‘warn’ param of builtin.command is deprecated.

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html)

Sad Face.

Is there something that takes over the job of warn:false now that warn:false is deprecated?

Is there some other way to install RPMs from yum repos on Centos7 that doesn’t involve installing python2 or using builtin.command or at least doesn’t give me warnings?

Thanks!

PS I love Ansible, and I love the way you aren’t afraid to change it to make it better.

---

<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:** [September 28, 2022, 5:11pm UTC](https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153/2 "2022-09-28T17:11:15Z")

</div>

Hopefully your teams are already thinking about a life without CentOS 7.  
It has an end of life as a downstream product of Red Hat EL of June 30, 2024.

[https://www.centosblog.com/centos-eol-dates/](https://www.centosblog.com/centos-eol-dates/)

Doesn’t CentOS 7 come with Python 2 installed by default? RHEL7 does. Are you removing it when installing Python 3?

Walter

---

<div class="post-metadata">

**Author:** ![m.nelson](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@m.nelson](https://forum.ansible.com/u/m.nelson)\
**Post date:** [September 28, 2022, 5:14pm UTC](https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153/3 "2022-09-28T17:14:42Z")

</div>

Hi,

I have managed to by-pass such issues by setting the ansible\_python\_interpreter on the CentOS 7 hosts.

May not be the same issue, but just something to pay attention to.

Regards,

Antuelle78

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 28, 2022, 5:23pm UTC](https://forum.ansible.com/t/centos7-python3-yum-dnf-builtin-command-oh-my/37153/4 "2022-09-28T17:23:29Z")

</div>

Effectively, you have to use `ansible_python_interpreter=/usr/bin/python` for any tasks that interact with `yum`. This is because the `yum` python bindings are only available via the default system python 2 at /usr/bin/python

It can be set on a per task basis under `vars:` for that task, if you only want to drop down to Py2 for the `yum` tasks, but it will have to be explicitly set for every `yum` task.

Otherwise, just using the system python2 for everything on CentOS7 will be much easier to manage.
