使用 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"}
原因
缺少 Python 的docker
库
解决方案
我的远程服务器是 Ubuntu,所以可以直接使用apt
安装
sudo apt install docker-python
写在 Ansible 的 playbook 里边就是
- name: install python docker lib
apt:
name: docker-python
state: present
评论