我正在尝试使用 Ansible Container 作为一个基本示例,该示例应该在映像中安装 Node。当我使用该ansible-container build
命令时,在成功构建导体映像后,它使第一个任务失败并出现sudo
相关错误。有问题的任务需要root
特权才能执行。
我正在运行 Debian GNU/Linux 9.2 (stretch),并通过 Docker APT 存储库安装了 Docker 17.09.0-ce。我尝试使用 Debian Stretch (2.2.1.0-2) 和 Pypi (2.4.1.0) 的 Ansible。我从 Pypi (0.9.3rc0) 和最新的 Git 源中尝试了 Ansible Container。我总是得到完全相同的错误输出。
Ansible 模块抱怨以下内容:
sudo: error while loading shared libraries: libsudo_util.so.0: cannot open shared object file: No such file or directory
正在运行的任务如下所示:
- name: Add the Node Source repository signing certificate to APT
apt_key:
id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
keyserver: hkps://hkps.pool.sks-keyservers.net
become: yes
我尝试创建的导体和服务都使用debian:stretch
基本图像。
我正在运行ansible-container build
带有sudo
前缀的命令,因为只能root
访问我系统上的 Docker 套接字。
这是我的内容container.yml
:
version: "2"
settings:
conductor:
base: debian:stretch
project_name: container_test
services:
nodejs:
from: debian:stretch
roles:
- nodejs
registries: {}
这是完整的错误输出:
Building Docker Engine context...
Starting Docker build of Ansible Container Conductor image (please be patient)...
Parsing conductor CLI args.
Docker™ daemon integration engine loaded. Build starting. project=container_test
Building service... project=container_test service=nodejs
PLAY [nodejs] ******************************************************************
TASK [Gathering Facts] *********************************************************
ok: [nodejs]
TASK [nodejs : Add the Node Source repository signing certificate to APT] ******
fatal: [nodejs]: FAILED! => {"changed": false, "module_stderr": "sudo: error while loading shared libraries: libsudo_util.so.0: cannot open shared object file: No such file or directory\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 127}
to retry, use: --limit @/tmp/tmpTRBQDe/playbook.retry
PLAY RECAP *********************************************************************
nodejs : ok=1 changed=0 unreachable=0 failed=1
ERROR Error applying role! engine=<container.docker.engine.Engine object at 0x7f84da0c5ed0> exit_code=2 playbook=[{'hosts': u'nodejs', 'roles': ['nodejs'], 'vars': {}}]
Traceback (most recent call last):
File "/usr/local/bin/conductor", line 11, in <module>
load_entry_point('ansible-container', 'console_scripts', 'conductor')()
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/cli.py", line 408, in conductor_commandline
**params)
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/core.py", line 843, in conductorcmd_build
raise RuntimeError('Build failed.')
RuntimeError: Build failed.
Conductor terminated. Cleaning up. command_rc=1 conductor_id=e8899239ad1017a89acc97396d38ab805d937a7b3d74e5a7d2741d7b1124bb0c save_container=False
ERROR Conductor exited with status 1