Ansible-Playbook:错误消息“无法找到任何要使用的 pip3。需要安装 pip”

dan*_*aso 5 ansible

我尝试在我的剧本中通过 ansible 安装 boto3。

我试图在我的主机上创建一个新用户。

- name: "test user"
  hosts: test
  tasks:
   - name: "install boto3"
      pip:
        name: boto3
        executable: pip3
Run Code Online (Sandbox Code Playgroud)

我收到了这条消息:

{"changed": false, "msg": "Unable to find any of pip3 to use.  pip needs to be installed."}
Run Code Online (Sandbox Code Playgroud)

小智 8

在失败的步骤之前安装 Python3-pip

- name: install pip3
  apt: name=python3-pip state=present 
Run Code Online (Sandbox Code Playgroud)


小智 2

首先,这些是 ansible 文档中指定的 pip ansible 模块的要求,文档链接:https: //docs.ansible.com/ansible/latest/modules/pip_module.html

  • 虚拟环境
  • 设置工具

其次,您在可执行字段中提到了pip3,这使得它使用python3,并且可能主机上没有安装python3而python2可用。

因此,要么保留该字段,要么检查安装的正确 python 版本并相应地更新可执行字段的值。