Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pip 为什么不是';是否负责我的系统代理设置?_Pip_Ansible - Fatal编程技术网

Pip 为什么不是';是否负责我的系统代理设置?

Pip 为什么不是';是否负责我的系统代理设置?,pip,ansible,Pip,Ansible,我是那些幸运的人之一,有一个破坏SSL的公司代理/ 我的环境已正确配置了http\U代理、https\U代理、http\U代理和https\U代理。我通过/etc/profile.d中的shell脚本进行配置,该脚本为我设置了所有4个环境变量 我正在尝试使用Ansible从pip安装软件包。这是我的问题 我可以登录到系统并键入以下命令: pip install --trusted-host pypi.python.org robotframework 。。。它会起作用的。我试着在Ansible

我是那些幸运的人之一,有一个破坏SSL的公司代理/

我的环境已正确配置了http\U代理、https\U代理、http\U代理和https\U代理。我通过/etc/profile.d中的shell脚本进行配置,该脚本为我设置了所有4个环境变量

我正在尝试使用Ansible从pip安装软件包。这是我的问题

我可以登录到系统并键入以下命令:

pip install --trusted-host pypi.python.org robotframework
。。。它会起作用的。我试着在Ansible内部使用
command
pip
模块做同样的事情。没有快乐

使用
pip
模块:

- name: install robotframework
  pip: name=robotframework extra_args='--trusted-host pypi.python.org'
  become: true
- name: install robotframework
  command: "pip install --trusted-host pypi.python.org robotframework"
  become: true
结果如下:

fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/bin/pip install --trusted-host pypi.python.org robotframework", "failed": true, "
invocation": {"module_args": {"chdir": null, "editable": true, "executable": null, "extra_args": "--trusted-host pypi.python.org", "name": "
robotframework", "requirements": null, "state": "present", "umask": null, "use_mirrors": true, "version": null, "virtualenv": null, "virtual
env_command": "virtualenv", "virtualenv_python": null, "virtualenv_site_packages": false}, "module_name": "pip"}, "msg": "stdout: Collecting
 robotframework\n\n:stderr: You are using pip version 7.1.0, however version 9.0.1 is available.\nYou should consider upgrading via the 'pip
 install --upgrade pip' command.\n  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolEr
ror('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=3, connect=None, read=No
ne, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotfr
amework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.
', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) afte
r connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Re
try(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network i
s unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by '
ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=3, connect=Non
e, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simp
le/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connectio
n aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=1, connect=None, read=None, redirect=N
one)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Re
trying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101,
'Network is unreachable'))': /simple/robotframework/\n  Could not find a version that satisfies the requirement robotframework (from version
s: )\nNo matching distribution found for robotframework\n"}
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["pip", "install", "--trusted-host", "pypi.python.org", "robotframework"], "delta":
"0:03:16.916685", "end": "2016-11-10 13:26:12.486105", "failed": true, "invocation": {"module_args": {"_raw_params": "pip install --trusted-
host pypi.python.org robotframework", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": tru
e}, "module_name": "command"}, "rc": 1, "start": "2016-11-10 13:22:55.569420", "stderr": "You are using pip version 7.1.0, however version 9
.0.1 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n  Retrying (Retry(total=4, connect=None, rea
d=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/rob
otframework/\n  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection abor
ted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None))
after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying
 (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Netwo
rk is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken
by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=4, connect
=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /
simple/robotframework/\n  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Conne
ction aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redire
ct=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(1
01, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connecti
on broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Could not find a versi
on that satisfies the requirement robotframework (from versions: )\nNo matching distribution found for robotframework", "stdout": "Collectin
g robotframework", "stdout_lines": ["Collecting robotframework"], "warnings": []}
使用
命令
模块:

- name: install robotframework
  pip: name=robotframework extra_args='--trusted-host pypi.python.org'
  become: true
- name: install robotframework
  command: "pip install --trusted-host pypi.python.org robotframework"
  become: true
结果如下:

fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/bin/pip install --trusted-host pypi.python.org robotframework", "failed": true, "
invocation": {"module_args": {"chdir": null, "editable": true, "executable": null, "extra_args": "--trusted-host pypi.python.org", "name": "
robotframework", "requirements": null, "state": "present", "umask": null, "use_mirrors": true, "version": null, "virtualenv": null, "virtual
env_command": "virtualenv", "virtualenv_python": null, "virtualenv_site_packages": false}, "module_name": "pip"}, "msg": "stdout: Collecting
 robotframework\n\n:stderr: You are using pip version 7.1.0, however version 9.0.1 is available.\nYou should consider upgrading via the 'pip
 install --upgrade pip' command.\n  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolEr
ror('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=3, connect=None, read=No
ne, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotfr
amework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.
', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) afte
r connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Re
try(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network i
s unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by '
ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=3, connect=Non
e, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simp
le/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connectio
n aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=1, connect=None, read=None, redirect=N
one)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Re
trying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101,
'Network is unreachable'))': /simple/robotframework/\n  Could not find a version that satisfies the requirement robotframework (from version
s: )\nNo matching distribution found for robotframework\n"}
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["pip", "install", "--trusted-host", "pypi.python.org", "robotframework"], "delta":
"0:03:16.916685", "end": "2016-11-10 13:26:12.486105", "failed": true, "invocation": {"module_args": {"_raw_params": "pip install --trusted-
host pypi.python.org robotframework", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": tru
e}, "module_name": "command"}, "rc": 1, "start": "2016-11-10 13:22:55.569420", "stderr": "You are using pip version 7.1.0, however version 9
.0.1 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n  Retrying (Retry(total=4, connect=None, rea
d=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/rob
otframework/\n  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection abor
ted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redirect=None))
after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying
 (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Netwo
rk is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken
by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=4, connect
=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /
simple/robotframework/\n  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Conne
ction aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=2, connect=None, read=None, redire
ct=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(1
01, 'Network is unreachable'))': /simple/robotframework/\n  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connecti
on broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/robotframework/\n  Could not find a versi
on that satisfies the requirement robotframework (from versions: )\nNo matching distribution found for robotframework", "stdout": "Collectin
g robotframework", "stdout_lines": ["Collecting robotframework"], "warnings": []}
我完全不知所措。我认为root用户可能很有趣,直到我以root用户身份登录并在shell中成功运行pip命令。我知道我使用的是旧版本的pip(感谢EPEL),但这不应该导致
命令调用失败。即使我尝试像警告状态那样升级pip,我也会得到同样的结果

唯一有效的方法是在任务中冗余指定代理url:

- name: install robot framework
  pip: name=robotframework extra_args='--trusted-host pypi.python.org'
  environment:
    http_proxy: http://proxy1.example.com:8080
    https_proxy: http://proxy1.example.com:8080
    HTTP_PROXY: http://proxy1.example.com:8080
    HTTPS_PROXY: http://proxy1.example.com:8080
  become: true
  become_user: root
我为什么要这样做?如果我以root用户身份登录,我可以看到环境变量已设置。我也不需要把它们放在Ansible里

如果我以root用户身份登录,我可以看到环境变量已设置。 我也不需要把它们放在Ansible里

不正确!:)您可能正在像
~/.bashrc
这样的文件中设置这些变量,该文件仅在交互式shell上运行

这里专门介绍了如何处理环境变量,特别强调了代理的使用