Ansible - 找不到 pip [英] Ansible - pip not found
问题描述
我收到此错误:
TASK [pip] *********************************************************************
failed: [default] (item=urllib3) =>
{"changed": false, "item": "urllib3",
"msg": "Unable to find any of pip2, pip to use. pip needs to be installed."}
根据建议,我运行以下命令:
Upon a suggestion I run following command:
ansible default -a "which pip"
我收到一个错误:
default | FAILED | rc=1 >>
non-zero return code
所以我猜这意味着没有安装 pip.我尝试使用以下方法安装 pip:
So I guess that means no pip installed. I tried installing pip using:
ansible default -a "easy_install pip"
我收到以下错误:
default | FAILED | rc=2 >>
[Errno 2] No such file or directory
有什么想法吗?
更新在 play_local.yaml 中,我有以下任务:
UPDATE In play_local.yaml, I have the following task:
- name: Prepare system
hosts: default
become: yes
gather_facts: false
pre_tasks:
- raw: sudo apt-get -y install python python-setuptools python-pip build-essential libssl-dev libffi-dev python-dev easyinstall pip
- file: path=/etc/sudoers.d/ssh-auth-sock state=touch mode=0440
#- lineinfile: line='Defaults env_keep += "SSH_AUTH_SOCK"' path=/etc/sudoers.d/ssh-auth-sock
- replace:
path: /etc/apt/sources.list
regexp: 'br.'
replace: ''
这个任务不应该安装pip吗?
Shouldn't this task install pip?
推荐答案
可能是 pip 被散列了.意思是pip安装在路径x(可能是/usr/local/bin/pip
),然而,缓存在路径y(可能是/usr/bin/pip)
.您可以从 - ansible default -m shell -a ‘type pip’
确认.要解决此问题,您需要运行 - ansible default -m shell -a ‘hash -r’
.
May be pip is hashed. Meaning pip is installed at path x (may be /usr/local/bin/pip
), however, cached at path y (may be /usr/bin/pip)
. You can confirm that from - ansible default -m shell -a ‘type pip’
. To resolve this you’ll need to run - ansible default -m shell -a ‘hash -r’
.
顺便说一句,您也可以使用命令模块代替 shell.
BTW, you can also use command module instead of shell.
这篇关于Ansible - 找不到 pip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!