我正在研究http://docs.ansible.com/ansible-container/getting_started.html中提到的ansible容器示例,并在进行ansible-container构建时遇到错误。
容器类型是码头工人。
我是Ansible容器模块的新手,非常感谢任何帮助。谢谢!!
[user@hostname hello-world]$ sudo pip install ansible-container[docker]
Collecting ansible-container[docker]
Using cached ansible-container-0.9.2.tar.gz
Requirement already satisfied: Jinja2>=2.9 in /usr/lib64/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: pip>=6.0 in /usr/lib/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: PyYAML>=3.12 in /usr/lib64/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: requests>=2 in /usr/lib/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: ruamel.yaml>=0.14.2 in /usr/lib64/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: six>=1.10 in /usr/lib/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: structlog[dev]>=16.1 in /usr/lib/python2.7/site-packages (from ansible-container[docker])
# These are the python requirements for your Ansible Container builder.
Requirement already satisfied: docker>=2.4.0 in /usr/lib/python2.7/site-packages (from ansible-container[docker])
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/site-packages (from Jinja2>=2.9->ansible-container[docker])
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.7/site-packages (from requests>=2->ansible-container[docker])
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python2.7/site-packages (from requests>=2->ansible-container[docker])
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python2.7/site-packages (from requests>=2->ansible-container[docker])
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/python2.7/site-packages (from requests>=2->ansible-container[docker])
Requirement already satisfied: ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" in /usr/lib64/python2.7/site-packages (from ruamel.yaml>=0.14.2->ans
ible-container[docker])
Requirement already satisfied: colorama; extra == "dev" in /usr/lib/python2.7/site-packages (from structlog[dev]>=16.1->ansible-container[docker])
Requirement already satisfied: backports.ssl-match-hostname>=3.5; python_version < "3.5" in /usr/lib/python2.7/site-packages (from docker>=2.4.0->ansible-container[docker])
Requirement already satisfied: ipaddress>=1.0.16; python_version < "3.3" in /usr/lib/python2.7/site-packages (from docker>=2.4.0->ansible-container[docker])
Requirement already satisfied: docker-pycreds>=0.2.2 in /usr/lib/python2.7/site-packages (from docker>=2.4.0->ansible-container[docker])
Requirement already satisfied: websocket-client>=0.32.0 in /usr/lib/python2.7/site-packages (from docker>=2.4.0->ansible-container[docker])
Installing collected packages: ansible-container
Running setup.py install for ansible-container ... done
Successfully installed ansible-container-0.9.2
[user@ hello-world]$
[user@hostname hello-world]$ ls -alrt
total 40
-rw-rw-r--. 1 user user 144 Mar 31 00:28 ansible.cfg
-rw-rw-r--. 1 user user 1181 Mar 31 00:28 meta.yml
-rw-rw-r--. 1 user user 298 Mar 31 00:28 requirements.yml
-rw-rw-r--. 1 user user 31 Mar 31 00:29 requirements.txt
-rw-rw-r--. 1 user user 108 Mar 31 00:29 helloworld.py
drwxrwxr-x. 3 user user 18 Mar 31 00:33 roles
-rw-rw-r--. 1 user user 2706 Mar 31 00:35 container.yml
-rw-rw-r--. 1 user user 130 Mar 31 00:59 ansible-requirements.txt
drwx------. 12 user user 4096 Mar 31 00:59 ..
drwxrwxr-x. 3 user user 4096 Mar 31 01:00 .
-rw-rw-r--. 1 user user 78 Mar 31 01:00 =36.2.7
[user@hostname hello-world]$
[user@hostname hello-world]$ sudo ansible-container build
ERROR Unknown exception
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/container/cli.py", line 299, in __call__
getattr(core, u'hostcmd_{}'.format(args.subcommand))(**vars(args))
File "/usr/lib/python2.7/site-packages/container/__init__.py", line 28, in __wrapped__
return fn(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/container/core.py", line 156, in hostcmd_build
config['services'], **kwargs)
File "/usr/lib/python2.7/site-packages/container/utils/loader.py", line 16, in load_engine
package='container')
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/lib/python2.7/site-packages/container/docker/engine.py", line 51, in <module>
container.__version__
ImportError: You must install Ansible Container with Docker(tm) support. Try:
pip install ansible-container[docker]==0.9.2
[user@sudo hello-world]$
答案 0 :(得分:1)
我建议使用virtualenv
。
在这里查看完整的样本。首先,在其中安装virtualenv和ansible
$ sudo pip install virtualenv
$ virtualenv venv
$ source venv/bin/activate
$ pip install ansible
$ pip install ansible-container[docker]
$ pip install docker==2.7.0
然后,克隆样本并构建它
$ git clone https://github.com/mkowsiak/ansible-with-big-file.git
$ cd ansible-with-big-file
$ git checkout smaller-file-that-works
$ ansible-container build