I have an state in a salt receipt that fails to install some sources using pip. But using pip from the shell what I think is the equivalent works. So it isn't really the equivalent and there something I miss that I cannot see.
I like to mention at the very beginning that the minion doesn't have full internet access and it shouldn't have.
{% set PLUGINSSRC='/usr/local/src' %}
git_sardana-xaira:
git.latest:
- name: https://...
- target: {{ PLUGINSSRC }}/sardana_xaira
- rev: 0.0.1
pip_git_sardana-xaira:
pip.installed:
- onchanges:
- git: git_sardana-xaira
- target: {{ PLUGINSSRC }}/sardana_xaira
- bin_env: '/usr/bin/pip3'
- no_deps: True
- require:
- pkg: python3-pip
The reduced return of this is:
ID: pip_git_sardana-xaira
Function: pip.installed
Result: False
Comment: Failed to install packages: pip_git_sardana-xaira. Error: Collecting pip_git_sardana-xaira Exception:
(...)
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
(...)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3b474fe400>: Failed to establish a new connection: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
(...)
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
But if, instead of use salt, I use the shell in the minion:
$ export PLUGINSSRC=/usr/local/src
$ sudo /usr/bin/pip3 install $PLUGINSSRC/sardana_xaira --no-deps
$ /usr/bin/pip3 list | grep xaira
sardana-xaira (0.0.1)
There would be something missing in the salt state that produces a different execution than the one in the shell. I also like to find which connection is failing when I use salt.
Following the documentation of the pip state there is a difference between name and target.
name
The name of the python package to install. You can also specify version numbers here using the standard operators ==, >=, <=. If requirements is given, this parameter will be ignored.
target
Install packages into target dir
The original receipt posted here was misunderstanding those two parameters.
The receipt that corresponds with the shell equivalent for pip would be:
pip_git_sardana-xaira:
pip.installed:
- onchanges:
- git: git_sardana-xaira
- name: {{ PLUGINSSRC }}/sardana_xaira
- bin_env: '/usr/bin/pip3'
- no_deps: True
- require:
- pkg: python3-pip