S3 problem ( ImportError: No module named hashlib )

Hi,

I’m running ansible 1.3 from git on RHEL5 and is all working great, I’m trying to get the s3 module up and running for some log archiving but when i try something like

tasks:

  • name: GET OBJECT from S3
    local_action: s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC_0001.JPG dest=/tmp/DSC_0001.pg overwrite=true

ansible-playbook s3test.yml -vv

PLAY [cobbler] ****************************************************************

TASK: [GET OBJECT from S3] ****************************************************
<127.0.0.1> REMOTE_MODULE s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC_0001.JPG dest=/tmp/DSC_0001.pg overwrite=true
failed: [cobbler] => {“failed”: true, “parsed”: false}
invalid output was: Traceback (most recent call last):
File “/home/sgoodliff/.ansible/tmp/ansible-1379592526.12-166004534605062/s3”, line 113, in ?
import hashlib
ImportError: No module named hashlib

FATAL: all hosts have already failed – aborting

I installed boto from git and lss3 works for example.

Any ideas ? I guess its a python 2.4 / 2.6 issue or the interaction between ansible and boto.

Thanks

Steve

Yes, hashlib is python 2.5+, so that is a bug. Could you open a github issue for this? Thanks!

Hi,

Issue #4174 raised

thanks

Steve

Hello,

ansible/library/cloud/s3 has #!/usr/bin/python as the 1st line. setting it to #!/usr/bin/env python fixes it for me.

is that how it should be or am I going to run into more problems changing that ?

Thanks

Hi Steven,

If you can please ask new questions in new threads that would be appreciated.

Meanwhile, the answer to your question is “ansible_python_interpreter”, which is covered in the early sections of the documentation.

(/usr/bin/env incorrectly assumes the executable is always named “python”, which is not actually true, because sometimes it’s named python26. More so, it relies on a user path and wrongly assumes the user account has the right python ahead in the path)

Hi,

I tried the setting ansible_python_interpreter in the playbook and it didnt help. I’ve also tried in the inventory file as below

cobbler ansible_python_interpreter=/usr/bin/python26

both gave exactly the same error as before.

So must be down to some oddity in my setup but if my workaround is incorrect im not sure where to look now or how to proceed.

I thought it was related question / answer hence the same thread.

I’d have to see your playbook to make sure, but possibly you’re talking to a different host.

Since you mentioned ‘s3’, perhaps you are doing this as “local_action” ?

Hi,

Yep its a local action that just runs

tasks:

  • name: GET OBJECT from S3
    local_action: s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC_0001.JPG dest=/tmp/DSC_0001.pg overwrite=true mode=get

thanks again

Hi Steven,

Since it’s local action this I think is a known issue where ansible_python_interpreter is not pulled from localhost for local action.

Can you see if it is set there and see if it helps?

localhost ansible_python_interpreter=/usr/bin/whatever

Thanks!

Hi,

Yeah thats sorted it out.

Thanks very much.

Steve