= 2.7) or……" /> = 2.7) or……" />

使用 Ansible 中的 docker_image 模块时报错

环境

  • Ansible 2.9.9

报错信息

fatal: [demo3]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on ubuntu-bionic's Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via pip install docker or pip install docker-py (Python 2.6). The error was: No module named requests.exceptions"}


原因

缺少pythondocker


解决方案

我的远程服务器是Ubuntu,所以可以直接使用apt安装

    sudo apt install docker-python

写在Ansibleplaybook里边就是

- name: install python docker lib
  apt:
      name: docker-python
      state: present
点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注