# Found bug in "apt\_rpm" module, fixed it.  Not sure how to help.

**URL:** <https://forum.ansible.com/t/found-bug-in-apt-rpm-module-fixed-it-not-sure-how-to-help/23404>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [January 7, 2017, 8:48pm UTC](https://forum.ansible.com/t/found-bug-in-apt-rpm-module-fixed-it-not-sure-how-to-help/23404 "2017-01-07T20:48:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pallenrupp](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@pallenrupp](https://forum.ansible.com/u/pallenrupp)\
**Post date:** [January 7, 2017, 8:48pm UTC](https://forum.ansible.com/t/found-bug-in-apt-rpm-module-fixed-it-not-sure-how-to-help/23404/1 "2017-01-07T20:48:28Z")

</div>

Hello, this is my first post to the ansible community.  
I’m a newby to Ansible, but a very experienced python developer.  
Anyway, after installing the latest Ansible 2.2.2.0, I tried out a simple module call to verify if a RPM package existed on some RHEL 6/7 systems. Anyway, the module failed, with the error:

“cannot find /usr/bin/apt-get and/or /usr/bin/rpm”

My first curiosity was to figure out what python module they used to execute “rpm” or “apt-get”, and see what path it used (if any) and how to correct. Somebody else had a similar problem, and the answers coming back were focusing on the user’s PATH or SUDO configuration, but there was never a resolution.

(That post is here → [https://groups.google.com/forum/#!searchin/ansible-project/executable$20not$20found%7Csort:relevance/ansible-project/zl6l6i0bBMc/vFCNiEYq3-IJ](https://groups.google.com/forum/#!searchin/ansible-project/executable$20not$20found%7Csort:relevance/ansible-project/zl6l6i0bBMc/vFCNiEYq3-IJ)

Anyway, I , decided to take a look at “apt\_rpm.py” directly, and lo and behold, I think I found the problem. In the very beginning of the “main()” function, the author tries determine if either “apt-get” or “rpm” are available…and if so continue on, or FAIL if not. Makes sense? However, way the if conditional was written is kind of confusing, and I believe it exits with a FAIL if only the ‘apt-get’ is missing, which I encounter on a RHEL system. To make a long story short, I rewrote the if conditional to be a little clearer, and IT WORKS!.

Here’s what I did:

Replace:

153 if not os.path.exists(APT\_PATH) or not os.path.exists(RPM\_PATH):  
154 module.fail\_json(msg=“cannot find /usr/bin/apt-get and/or /usr/bin/rpm”)

With…  
153 if (os.path.exists(APT\_PATH) or os.path.exists(RPM\_PATH)):  
154 pass  
155 else:  
156 module.fail\_json(msg=“cannot find /usr/bin/apt-get and/or /usr/bin/rpm”)

I believe this bug has existed from v1.5, and kind of surprised it hasn’t been found.  
Let me know how I can either:

1. Who or how should I get this to an existing Ansible developer to look at?
2. Please direct me to how I can become an ansible developer and start writing high-quality code to help you’alls out. 🙂

Thank You  
Peter

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 9, 2017, 6:20pm UTC](https://forum.ansible.com/t/found-bug-in-apt-rpm-module-fixed-it-not-sure-how-to-help/23404/2 "2017-01-09T18:20:35Z")

</div>

Hi,

​To start contributing you can just create a pull request against our github repo : [https://github.com/ansible/ansible](https://github.com/ansible/ansible)​

I recommend reading through developer information docs [http://docs.ansible.com/ansible/dev\_guide/index.html](http://docs.ansible.com/ansible/dev_guide/index.html)
