我正在尝试使用ansible-container build命令创建简单的Docker镜像。
我无法找到解决我遇到的错误的方法。
以下是最重要的文件:
main.yml
---
- hosts: scala-akka
roles:
- java8
container.yml
version: "1"
services:
scala-akka:
image: ubuntu:14.04
registries: {}
角色/ java8 /任务/ main.yml
---
# Add oracle ppa to apt_key
- name: Add oracke ppa to apt_repository
apt_repository:
repo: 'ppa:webupd8team/java'
# Install Oracle Java8
- name: Install oracle Java8
apt:
name: oracle-java8-installer
state: present
每次尝试运行时都会遇到错误
ansible-container --debug build
ansible-container_1 | Host scala-akka running
ansible-container_1 | Using /ansible-container/ansible/ansible.cfg as config file
ansible-container_1 |
ansible-container_1 | PLAYBOOK: main.yml *************************************************************
ansible-container_1 | 1 plays in main.yml
ansible-container_1 |
ansible-container_1 | PLAY [scala-akka] **************************************************************
ansible-container_1 |
ansible-container_1 | TASK [setup] *******************************************************************
ansible-container_1 | <ansible_scala-akka_1> ESTABLISH DOCKER CONNECTION FOR USER: root
ansible-container_1 | <ansible_scala-akka_1> EXEC ['/usr/bin/docker', 'exec', '-i', u'ansible_scala-akka_1', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1486389293.49-274006099773087 `" && echo ansible-tmp-1486389293.49-274006099773087="` echo $HOME/.ansible/tmp/ansible-tmp-1486389293.49-274006099773087 `" ) && sleep 0\'']
ansible-container_1 | <ansible_scala-akka_1> PUT /tmp/tmpi6WTY3 TO /root/.ansible/tmp/ansible-tmp-1486389293.49-274006099773087/setup
ansible-container_1 | <ansible_scala-akka_1> EXEC ['/usr/bin/docker', 'exec', '-i', u'ansible_scala-akka_1', u'/bin/sh', '-c', u'/bin/sh -c \'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1486389293.49-274006099773087/setup; rm -rf "/root/.ansible/tmp/ansible-tmp-1486389293.49-274006099773087/" > /dev/null 2>&1 && sleep 0\'']
ansible-container_1 | fatal: [scala-akka]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "setup"}, "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
ansible-container_1 |
ansible-container_1 | NO MORE HOSTS LEFT *************************************************************
ansible-container_1 |
ansible-container_1 | PLAY RECAP *********************************************************************
ansible-container_1 | scala-akka : ok=0 changed=0 unreachable=0 failed=1
ansible-container_1 |
ansible-container_1 | [WARNING]: Could not create retry file 'main.retry'. [Errno 2] No such
ansible-container_1 | file or directory: ''
ansible_ansible-container_1 exited with code 1
Aborting on container exit...
Stopping ansible_scala-akka_1 ... done
Ansible playbook run failed.
Cleaning up Ansible Container builder...
Cleaning up temporary directory /tmp/tmpme3nWT...
Ansible build failed
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/container/cli.py", line 212, in commandline
getattr(engine, u'cmdrun_{}'.format(args.subcommand))(**vars(args))
File "/usr/local/lib/python2.7/dist-packages/container/engine.py", line 384, in cmdrun_build
raise RuntimeError(u'Ansible build failed')
RuntimeError: Ansible build failed
它看起来像某种python问题,但我仍然不知道如何解决这个问题。
有什么建议吗?谢谢!
答案 0 :(得分:2)
大多数Ansible模块都需要在目标主机上使用Python(在您的情况下为容器)
ubuntu:14.04
Docker镜像没有预先安装。
在main.yml中使用它:
---
- hosts: scala-akka
gather_facts: false
pre_tasks:
- raw: 'which python || (apt-get -q -y update && apt-get install -q -y python-minimal)'
- setup:
roles:
- java8