pip 安装的盐收据

salt receipt for a pip install

我在 salt 收据中有一个状态无法使用 pip 安装某些源。但是使用 shell 中的 pip 我认为是等效的。所以它并不是真正的等价物,我错过了一些我看不到的东西。

我想在一开始就提到小黄人没有完整的互联网访问权限,它不应该有。

{% 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

减少的return是:

          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'

但是如果我不使用 salt,而是在 minion 中使用 shell:

$ 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)

salt state 中会缺少一些东西,它会产生与 shell 中不同的执行。我还喜欢在使用 salt 时查找哪个连接失败。

根据 pip state 的文档,名称和目标之间存在差异。

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

这里张贴的原始收据误解了这两个参数。

对应于 shell 等价点的收据为:

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