分子:测试角色:未能获得不允许的Dbus连接操作

问题描述 投票:0回答:1

我在分子测试中遇到问题。我已于2天前开始研究此工具以获取信息。

在运行Vagrant的Ubuntu VM上,我创建了一个角色并初始化Molecule的文件夹,并创建了一个testinfra测试文件(使用docker provider)。

错误是我的任务角色正在运行时,在检查服务运行的步骤中,它失败。

fatal: [instance]: FAILED! => {"changed": false, "msg": "Could not find the requested service httpd: "}

我被设计为在Centos映像上简单地安装2个软件包,包括httpd。

当我直接登录到Molecule VM时(因此通过docker),当我简单地键入systemctl时,错误消息是

Failed to get D-Bus connection: Operation not permitted

按照Geerlingguy的建议,我指定了映射到cgroup文件夹的卷

platforms:
  - name: instance
    #image: docker.io/pycontribs/centos:7
    image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro

该错误与Testinfra不相关,仅与docker构建的映像有关。

有人可以帮助我了解为什么出现此错误消息吗?

是因为在VirtualBox上的im由Vagrant运行了?

感谢大家阅读:-)

docker ansible vagrant molecule
1个回答
0
投票

我已根据分子文档(https://molecule.readthedocs.io/en/latest/examples.html#docker)在我的mocule.yml文件配置中添加了它:

平台:-名称:实例#image:docker.io/pycontribs/centos:7图片:geerlingguy / docker-centos7-ansible:latest功能:-SYS_ADMIN命令:/ sbin / init

systemctl现在可以正常工作

© www.soinside.com 2019 - 2024. All rights reserved.