lib/ansible/module_utils/known_hosts.py requires hashlib

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’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!

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.

                                      -Josh (jbs@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.

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).