# Tomcat restart failed...

**URL:** <https://forum.ansible.com/t/tomcat-restart-failed/22557>\
**Category:** Ansible Project\
**Created:** [September 15, 2016, 12:40pm UTC](https://forum.ansible.com/t/tomcat-restart-failed/22557 "2016-09-15T12:40:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![naaga.wip](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@naaga.wip](https://forum.ansible.com/u/naaga.wip)\
**Post date:** [September 15, 2016, 12:40pm UTC](https://forum.ansible.com/t/tomcat-restart-failed/22557/1 "2016-09-15T12:40:23Z")

</div>

Hi,

- hosts: dev\_tomcat  
vars:  
http\_port: 8080  
sudo: true  
sudo\_user: build  
tasks:

- name: copy\_shut  
copy: src=/etc/ansible/playbooks/scripts/shutdown\_all.sh dest=/tmp

- name: change\_permission\_shut  
file: path=/tmp/shutdown\_all.sh mode=777

- name: copy\_start  
copy: src=/etc/ansible/playbooks/scripts/startup\_all.sh dest=/tmp

- name: change\_permission\_start  
file: path=/tmp/startup\_all.sh mode=777

- name: stopping tomcat  
shell: /tmp/./shutdown\_all.sh

- name: starting tomcat

#command: sudo -u build /etc/init.d/tomcat start  
shell: /tmp/./startup\_all.sh

startup\_all.sh =\> /etc/init.d/tomcat start

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [September 16, 2016, 5:12pm UTC](https://forum.ansible.com/t/tomcat-restart-failed/22557/2 "2016-09-16T17:12:41Z")

</div>

My guess would be that your playbook tried to start it before it had finished shutting down.

Simplest thing to do would be wait a bit before trying the start, but it would be better to check it is down.

You could use wait\_for module to check it is down:  
[http://docs.ansible.com/ansible/wait\_for\_module.html](http://docs.ansible.com/ansible/wait_for_module.html)

Incidentally, checking that tomcat is fully up and ready to service requests is tricky as it seems to lock its listening port and then not respond on it for some time.

We used to just wait before polling a particular url but now we use a pattern similar to what is described here to poll until we get a 200

[https://groups.google.com/forum/#!searchin/ansible-project/do-until$20with$20uri$20module|sort:relevance/ansible-project/iLjIbsCASWU/ZmE-wYdtLQAJ](https://groups.google.com/forum/#!searchin/ansible-project/do-until$20with$20uri$20module%7Csort:relevance/ansible-project/iLjIbsCASWU/ZmE-wYdtLQAJ)

Hope this helps,

Jon
