我已按照以下步骤将Docker
和Ansible
安装到我的AWS Ec2 Linux:
sudo yum update -y
sudo yum install docker -v
sudo service docker start
sudo yum-config-manager --enable epel
sudo yum repolist
sudo yum install ansible
当我尝试使用ansible将docker
图像拖到我的AWS Ec2 Linux上时,发现以下错误消息。
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to import docker or docker-py - No module named docker. Try `pip install docker` or `pip install docker-py` (Python 2.6)"}
Docker版本
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a215d7133c34aa18e3b72b4a21fd0c6136
Built: Fri Oct 26 23:38:19 2018
OS/Arch: linux/amd64
Experimental: false
可用的版本是
ansible 2.6.8
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.6.9 (unknown, Nov 2 2017, 19:21:21) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
这是我的剧本档案的一部分
- name: Pull a container image
docker_container:
name: mynodejs
image: registry.gitlab.com/ppshein/test:latest
pull: yes
state: started
published_ports:
- 8080:80
请告诉我在AWS Ec2 Linux中缺少哪些配置。
答案 0 :(得分:1)
您需要安装Python docker
模块:
sudo yum install python-pip
sudo pip install docker
答案 1 :(得分:1)
对 ansible 2.9.1 和 Ubuntu 20.10 有用的是安装 python3-docker:
sudo apt-get install python3-docker
答案 2 :(得分:0)
将此ansible_python_interpreter
添加到您的“主机”文件中:
将[servers:vars]
更改为[your-group-of-server-names:vars]
对于Python> = 2.7
[servers:vars]
ansible_python_interpreter=/usr/bin/python3 # For Python3 [default Ubuntu-18.04]
Python <= 2.7
[servers:vars]
ansible_python_interpreter=/usr/bin/python # For Python2.7
答案 3 :(得分:0)
对于路过的人,通过apt
安装了ubuntu时遇到了同样的问题,在Ubuntu上给出了2.7.15。通过安装最新版本进行了修复:
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
到今天为止为2.9.2。