我正在爲任何Linux發行版上的Ansible.Galaxy編寫一本合適的劇本,其中包括install nginx。 但我覺得在包含Systemd的映像上使用Travis CI和Docker進行測試。因爲SystemD給出了一個錯誤:使用基於rpm的發行版測試劇本,systemd作爲Docker容器
Failed to get D-Bus connection: No connection to service manager.
正如你可以看到https://travis-ci.org/weldpua2008/ansible-nginx/jobs/78864352 時發生了錯誤。
所以我儘量表現吧:
~# git clone https://github.com/weldpua2008/ansible-nginx.git
~# cd ansible-nginx
~# docker run -ti --rm=true -v `pwd`:/ansible-nginx:rw centos:7 /bin/bash ^C
~# cd ansible-nginx/
~/ansible-nginx# docker run -ti --rm=true -v `pwd`:/ansible-nginx:rw centos:7 /bin/bash
[[email protected] /]# /ansible-nginx/tests/test-on-rpm.sh
TASK: [ansible-nginx | create document root directory if needed] **************
ok: [localhost]
TASK: [ansible-nginx | Starting nginx service] ********************************
failed: [localhost] => {"failed": true}
msg: no service or tool found for: nginx
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/test.retry
localhost : ok=5 changed=2 unreachable=0 failed=1
也許沒有這個服務?
[[email protected] /]# systemctl enable nginx.service
[[email protected] /]# systemctl -t service -a
Failed to get D-Bus connection: No connection to service manager.
[[email protected] /]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
這就是我嘗試在ansible啓動服務:https://github.com/weldpua2008/ansible-nginx/blob/master/tasks/main-centos.yml#L24
- name: Starting nginx service
service: name=nginx state=started
tags:
- nginx
我係有https://github.com/docker/docker/issues/7459
在你的CentOS 6劇本,它看起來像nginx重啓失敗,因爲該端口已被使用(https://travis-ci.org/weldpua2008/ansible-nginx/jobs/78864352#L3972) - 也許nginx需要以不同的方式重新啓動,或者已經在運行? – ocean