Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add httplib2 into ansible?

I am trying to use the get_url module for ansible and when I run it I get the following error:

failed: [localhost] => (item=10) => {"failed": true, "item": "10"}
msg: httplib2 is not installed

Now I have successfully installed httplib2 using pip:

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

But obviously that hasn't helped the situation. I can see that ansible is using a different PYTHON_PATH than the OS (where httplib2 is installed) but I cannot work out how to get a httplib2 installed into that path (other than copying it which isn't nice).

Any help greatly appreciate.

like image 338
mransley Avatar asked Jul 23 '15 19:07

mransley


2 Answers

If this is an ansible-playbook error, you can run a pip command to install the httplib2 artifact. Try running the following task before:

      tasks:
        - name: pip httplib2
          # ansible uri module requires httplib2
          pip: name=httplib2 extra_args="--user"
like image 120
user422930 Avatar answered Nov 12 '22 17:11

user422930


I ran into this problem on one of my Macs (I had been switching between a Homebrew Python installation and the system install recently, so something was funky anyways), and what ended up fixing it, at least for a particular session, was starting an interactive python session on the CLI and importing the library:

$ python
>>> import httplib2
>>> exit()
$ [continue what you were doing with ansible...]
like image 25
geerlingguy Avatar answered Nov 12 '22 16:11

geerlingguy