I'm facing some interesting voodoo when I try to install python packages with Ansible
using its pip module.
Here goes... If I try this:
$ sudo pip install sh
The sh
package installation succeeds with no errors at all.
That's is a good thing.
I will undo this:
$ sudo pip uninstall sh
The next thing I will try is using Ansible
:
$ ansible smith pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory
This fails. The error message is as follow (forgive me but I am working under firewalls with no internet access so I had to type it. I filtered thing that I didn't think would be necessary - if something is still missing tell me and I will update my question):
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Downloading http://host:port/packages/sh-1.09.tar.gz
...
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
copying sh.py -> build/lib.linux-i686-2.7
running install_lib
copying buikd/lib.linux-i686-2.7/sh.py -> /usr/local/lib/python2.7/dist-packages
error: /usr/local/lib/python2.7/dist-packages/sh.py: Permission denied
---------
:stderr: Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-zH3cTB/sh/setup.py' ... -- compile: failed with error code 1 in /tmp/pip-build-zH3cTB/sh
Naturally, I added to the last command --sudo
:
$ ansible smith -m pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory --sudo
This time I was speechless. It failed again:
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Could not find a version that satisfied the requirement (from versions: ) No matching distribution found for sh
Very weird. This goes for all python packages I am trying to install.
Additional information:
We have a pypi server where we put all our packages to install.
It is under host:port/simple
Also we use this pip.conf
file:
[global]
index-url = http://host:port/simple
trusted-host = host
Thanks in advance to all helpers.
OK, I understood what was going on.
The problem was that my pip.conf file was just for my user (under /home/user/.pip/pip.conf
)
I moved it to /etc/pip.conf and the problem solved.
An alternative solution wast to add to the arguments --trusted-host host
I worked with old version of pip for very long time and when I upgraded to the latest version I forgot to update the arguments.
Cheers!