Ansible - 找不到 pip

标签 ansible ansible-2.x

我收到此错误:

    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."}

根据建议,我运行以下命令:
ansible default -a "which pip"

我收到一个错误:
default | FAILED | rc=1 >>
non-zero return code

所以我想这意味着没有安装 pip。我尝试使用以下方法安装 pip:
ansible default -a "easy_install pip"

我收到以下错误:
default | FAILED | rc=2 >>
[Errno 2] No such file or directory

有任何想法吗?

更新
在 play_local.yaml 中,我有以下任务:
- 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吗?

最佳答案

好像没有安装pip,可以使用下面的任务来安装:

- name: Install pip
  apt:
    name: python-pip
    update_cache: yes
    state: present

关于Ansible - 找不到 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51997637/

相关文章:

ansible - 如何使用 Ansible 收集有关磁盘的信息

django - CLI 使用原始 python 在 Django 中创建 super 用户,没有 python shell

regex - Ansible 正则表达式从/etc/hosts 中删除匹配的 IP

ansible - 如何使用 ansible playbook 在 sudo 模式下运行命令?

Ansible 2.7 多行 ansible_management

ansible - 如何在 Ansible 中向已知主机添加 SSH 指纹?

ansible - 是否可以在连接失败时重试 Ansible?

linux - 将 rsa token 复制到组内的远程主机

Ansible 检查字典列表中是否存在键/值对

ansible - `remote_user` 在剧本和角色中被忽略