I have been trying to build a virtualmachine using ansible and packer. I tried to add a task to install jetty and it somehow fails to start and enable the service. The virtualmachine OS is Debain 7.11 and I'm running the packer command on an Ubuntu machine. This is the task I'm trying to run:
- name: install jetty
apt:
name: jetty
state: latest
And the task that fails is:
---
- name: restart jetty
command: service jetty restart
become: true
The error message I got is:
FAILED! => {"changed": true, "cmd": ["service", "jetty", "restart"], "delta": "0:00:05.029766", "end": "2017-06-23 14:11:03.850434", "failed": true, "rc": 1, "start": "2017-06-23 14:10:58.820668", "stderr": "", "stderr_lines": [], "stdout": "Starting Jetty servlet engine.: jetty Jetty servlet engine started, reachable on http://server:8080/.: jetty failed!", "stdout_lines": ["Starting Jetty servlet engine.: jetty Jetty servlet engine started, reachable on http://server:8080/.: jetty failed!"]}
Ansible version I'm using is 2.3 I have also tried downgrading to 1.9 it did not help. Any help would be appreciated.
Looks like the start problem is not in ansible: it's in your jetty application. If you launch sudo service jetty restart
on your remote host it may failed too.
Please go on your remote host and look at your jetty logs to find out why it didn't start.
BTW, you should use the service module with state: restarted
. (And it would be even better to call it in a handler)
- name: restart jetty
service:
name: jetty
state: restarted
become: true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.