这个 Ansible 角色已经被创建,并且这个 .travis.yml被用作一个例子来测试这个角色。除 sensu-client 外,所有服务都可以启动。
尝试解决问题
为了解决这个问题,在 travis 中添加了一个调试步骤。构建完成后抛出以下错误:
The command "sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
" exited with 1.
0.07s$ sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm sudo systemctl status sensu-client.service -l
● sensu-client.service - LSB: Sensu monitoring framework client
Loaded: loaded (/etc/rc.d/init.d/sensu-client)
Active: failed (Result: exit-code) since Mon 2016-08-08 00:18:20 UTC; 131ms ago
Docs: man:systemd-sysv-generator(8)
Process: 1534 ExecStart=/etc/rc.d/init.d/sensu-client start (code=exited, status=1/FAILURE)
Aug 08 00:18:19 c6354976113c systemd[1]: Starting LSB: Sensu monitoring framework client...
Aug 08 00:18:19 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 71: /etc/init.d/functions: No such file or directory
Aug 08 00:18:19 c6354976113c sensu-client[1534]: Starting sensu-client/etc/init.d/sensu-service: line 79: daemon: command not found
Aug 08 00:18:20 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 88: echo_failure: command not found
Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service: control process exited, code=exited status=1
Aug 08 00:18:20 c6354976113c systemd[1]: Failed to start LSB: Sensu monitoring framework client.
Aug 08 00:18:20 c6354976113c systemd[1]: Unit sensu-client.service entered failed state.
Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service failed.
当 ansible 角色部署在远程系统上时,sensu-client 启动,但它在 Travis 上失败,尽管其他服务能够启动。
简洁的
initscripts
包裹不见了。这是在将驻留在/etc/init.d
本地系统中的文件与驻留在 Travis 使用的 docker 容器中的文件进行比较后发现的。查询后/etc/init.d/functions
很清楚必须安装什么软件包。详细
中似乎缺少文件
/etc/init.d
,即:真的吗?为了检查是否添加了另一个调试步骤:
ls /etc/init.d
. 结果如下:functions
确实失踪了。这个帖子表明initscripts
需要安装。当这个包被添加到 Dockerfile并且构建再次运行时,它成功了。