lib/ansible/module_utils/known_hosts.py requires hashlib

50 views
Skip to first unread message

Josh Smift

unread,
Jul 25, 2014, 12:15:36 PM7/25/14
to ansible...@googlegroups.com
Between Ansible 1.5.3 and 1.6.6, lib/ansible/module_utils/known_hosts.py added

from hashlib import sha1

which doesn't work on target hosts who only have Python 2.4.

The 'git' module uses this, and produces this stacktrace on a target RHEL
5 system:

Traceback (most recent call last):
File "/home/ansible/.ansible/tmp/ansible-tmp-1406298245.3-265004186822038/git", line 1840, in ?
from hashlib import sha1
ImportError: No module named hashlib

If we modify known_hosts.py to just the import, like so:

+$ git diff -U0
diff --git a/lib/ansible/module_utils/known_hosts.py b/lib/ansible/module_utils/known_hosts.py
index 62600d7..90620f7 100644
--- a/lib/ansible/module_utils/known_hosts.py
+++ b/lib/ansible/module_utils/known_hosts.py
@@ -30 +30,5 @@ import hmac
-from hashlib import sha1
+try:
+ from hashlib import sha1
+except ImportError:
+ pass
+

that solves our immediate problem, because we don't actually happen to
need to do anything with known_hosts right now, but that would presumably
break things that actually need to use sha1 from hashlib, so that's
probably not a real fix. :^)

-Josh (j...@care.com)



This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

Michael DeHaan

unread,
Jul 25, 2014, 3:28:25 PM7/25/14
to ansible...@googlegroups.com
That's fine, feel free to send a pull request.

We don't have a workflow that involves patches to the mailing list, but pull requests do work great for this.

Thanks!



--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/21458.33423.536849.308170%40care.com.
For more options, visit https://groups.google.com/d/optout.

Josh Smift

unread,
Jul 25, 2014, 5:07:19 PM7/25/14
to ansible...@googlegroups.com
Heh, I didn't think to check this before I'd sent mail, but there's
actually already a fix for this in devel, in
https://github.com/ansible/ansible/commit/60451c20ab0cb8293a1ba51b48c600819a676626 --
it just hasn't made it into a release yet, I guess.

Michael DeHaan

unread,
Jul 25, 2014, 6:03:39 PM7/25/14
to ansible...@googlegroups.com
Yeah, it deserved to be but our last series of updates have been necessarily targeted.

We are possibly considering upping the 1.7 timetable and releasing in a couple of weeks (as mentioned, Windows will still be in beta, and hoping to extend module coverage more in 1.8 timeframe).




--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages