ansible Molecular docker服务无法启动

问题描述

我有一个有趣的剧本,但是在尝试用Molecular测试时,我无法启动docker服务。

这是我的Molecular.yml中的东西

UIScenesession.stateRestorationActivity

运行Ansible剧本时,我使用以下命令创建Docker容器:

platforms:
- name: instance
  image: oraclelinux:7
  command: /usr/sbin/init
  tmpfs:
   - /run
   - /run/lock
   - /tmp
 capabilities:
   - SYS_ADMIN
 volumes:
   - /sys/fs/cgroup:/sys/fs/cgroup:ro
 port_bindings:
   2424: 2424,2480: 2480
 pre_build_image: true

用分子测试时出错:

docker run -it --name=testing -d --rm --privileged --cap-add=SYS_ADMIN --tmpfs /run --tmpfs /run/lock --tmpfs /tmp -p 2424:2424 -p 2480:2480 -v /sys/fs/cgroup:/sys/fs/cgroup:ro  oraclelinux:7  /usr/sbin/init

我如何找出分子测试的问题?

更新:

    TASK [docker-role : Start docker] ******************************************
    fatal: [instance]: Failed! => {"changed": true,"cmd": "sudo systemctl start docker","delta": "0:00:00.613116","end": "2020-10-21 03:24:47.268335","msg": "non-zero return code","rc": 1,"start": "2020-10-21 03:24:46.655219","stderr": "Job for docker.service Failed because 
the control process exited with error code. See \"systemctl status docker.service\" and 
\"journalctl -xe\" for details.","stderr_lines": ["Job for docker.service Failed because the 
control process exited with error code. See \"systemctl status docker.service\" and \"journalctl 
-xe\" for details."],"stdout": "","stdout_lines": []}

我的理解是,它必须在安装了docker且需要启动其服务的docker容器中运行。

解决方法

也许我不太明白这个问题,但是有了分子,你不需要运行容器,分子为你做。

你可以试试这个:

molecule create # This would create the instance
molecule list # This would show you the molecule scenario status
molecule converge # This would run you molecule playbook that would run the role

实际上 molecule test 命令会运行所有这些步骤:

    --> Test matrix

└── default
    ├── lint
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    └── destroy

要使容器与应用的角色一起使用,您需要运行 converge 命令。

一旦收敛,你也可以通过分子进入容器:

molecule login --host instance