I've often found that using python from homebrew causes more problems than it 
solves.

You can probably do something like:

sudo PYTHONPATH="" /usr/bin/easy_install httplib2

On Mac, usually one of the first things I do is:

sudo /usr/bin/easy_install pip

Unfortunately that will try to squash pip provided by homebrew installed python 
as they both use /usr/local/bin/pip as their destination.

If you want to use python from homebrew, then your inventory modification is 
probably the right change to make.

Either that , or don't target localhost explicitly, remove localhost from your 
inventory and use local_action or delegate_to: localhost, which does some magic 
(implicit localhost) and uses the python binary used to invoke ansible as 
ansible_python_interpreter.
-- 
Matt Martz
[email protected]

On April 23, 2014 at 8:33:20 AM, Kesten Broughton 
([email protected]) wrote:

httplib2 is getting picked up from the same place for either python install.

[kbroughton@mb-kbroughton:Contents/MacOS] /usr/bin/python -c "import httplib2; 
print httplib2.__file__"

/usr/local/lib/python2.7/site-packages/httplib2/__init__.pyc

[kbroughton@mb-kbroughton:Contents/MacOS] /usr/local/bin/python -c "import 
httplib2; print httplib2.__file__"

/usr/local/lib/python2.7/site-packages/httplib2/__init__.pyc

PYTHONPATH is pointing there

[kbroughton@mb-kbroughton:Contents/MacOS] echo $PYTHONPATH 

/usr/local/lib/python2.7/site-packages:/Users/kbroughton/vcp/git/mentat/ansible/lib:

But i'm not sure how to force pip to install it to the location that ansible 
has access to.

[kbroughton@mb-kbroughton:Contents/MacOS] export PYTHONPATH=''

[kbroughton@mb-kbroughton:Contents/MacOS] echo $PYTHONPATH 



[kbroughton@mb-kbroughton:Contents/MacOS] pip install httplib2

Requirement already satisfied (use --upgrade to upgrade): httplib2 in 
/usr/local/lib/python2.7/site-packages

Cleaning up...

[kbroughton@mb-kbroughton:Contents/MacOS] 



I suppose that pip belongs to the homebrew installed python, and i don't have 
pip installed for /usr/bin/python.



Setting ansible_python_interpreter=/usr/local/bin/python in the hosts file 
fixes the problem.



kesten



On Tue, Apr 22, 2014 at 4:59 PM, Matt Martz <[email protected]> wrote:
Do you have 'localhost' defined in your inventory?  If so, have you specified 
ansible_python_interpreter=/usr/local/bin/python along with it in your 
inventory?

You do mention that /usr/bin/python has access to httplib2, but that could be 
due to something such as setting PYTHONPATH somewhere that would allow 
/usr/bin/python to load httplib2 that it wouldn't otherwise have access to, and 
as a result ansible is running without access to PYTHONPATH maybe...

The code that determines if you have httplib2 is somewhat simple:

HAS_HTTPLIB2 = True
try:
    import httplib2
except ImportError:
    HAS_HTTPLIB2 = False

And later if HAS_HTTPLIB2 is False, it fails with the message you are seeing.


Perhaps try running:

/usr/bin/python -c "import httplib2; print httplib2.__file__"
/usr/local/bin/python -c "import httplib2; print httplib2.__file__"

As well as looking at:

echo $PYTHONPATH

-- 
Matt Martz
[email protected]

On April 22, 2014 at 4:43:37 PM, Kesten Broughton 
([email protected]) wrote:

Running the task

 - name: Get tenant id
   uri: url="{{ os_service_endpoint }}/tenants?name={{tenant.name}}"
        method=GET
        timeout=30
        return_content=yes
        HEADER_User-Agent=python-keystoneclient
        HEADER_X-Auth-Token="{{keystone_admin_token}}"
        HEADER_Content-Type="application/json"
   register: register_tenant


TASK: [Get tenant id] ********************************************************* 

<localhost> REMOTE_MODULE uri 
url="http://example.com:35357/v2.0//tenants?name=tenant2"; method=GET timeout=30 
return_content=yes HEADER_User-Agent=python-keystoneclient 
HEADER_X-Auth-Token="*****" HEADER_Content-Type="application/json"

<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1398201502.91-131706600599036 && echo 
$HOME/.ansible/tmp/ansible-tmp-1398201502.91-131706600599036']

<localhost> PUT /var/folders/t2/h22337c12hn279xwd4s9fk7s8_088c/T/tmpLEIdmk TO 
/Users/kbroughton/.ansible/tmp/ansible-tmp-1398201502.91-131706600599036/uri

<localhost> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, 
key=turelpokuakqdltyqvhjhfyyvmrqaail] password: " -u root /bin/sh -c '"'"'echo 
SUDO-SUCCESS-turelpokuakqdltyqvhjhfyyvmrqaail; /usr/bin/python 
/Users/kbroughton/.ansible/tmp/ansible-tmp-1398201502.91-131706600599036/uri; 
rm -rf 
/Users/kbroughton/.ansible/tmp/ansible-tmp-1398201502.91-131706600599036/ 
>/dev/null 2>&1'"'"''



failed: [localhost] => {"failed": true, "item": ""}



msg: httplib2 is not installed

FATAL: all hosts have already failed -- aborting

-----------------
Running ansible 1.6 on a mac

Default python is 2.7.6 in /usr/local/bin/python .  That one can import 
httplib2.
[kbroughton@mb-kbroughton:lynx-ansible/21ct-ansible + (develop)] which python

/usr/local/bin/python

ansible seems to use /usr/bin/python, but that also can import httplib2

[kbroughton@mb-kbroughton:/21ct-ansible + (develop)] /usr/bin/python

Python 2.7.5 (default, Aug 25 2013, 00:04:04) 

[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import httplib2

>>>

The play is run against localhost (my mac) but even the 3 controller openstack 
nodes have httplib2 installed (though in dist-packages not site-packages 
because it is ubuntu).

any ideas?

--

Kesten Broughton
512 701 4209
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAO2fFsXRGrp20pH09FK_ez6FChYsMOFEjDoLhA3HQjmt-zPAJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

Kesten Broughton
512 701 4209

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/etPan.5357f36a.643c9869.9c54%40mobiletuvix.rackspace.corp.
For more options, visit https://groups.google.com/d/optout.

Reply via email to