parames
parames

Reputation: 107

How to run tomcat catalina script on Ansible

I am trying to setup Ansible playbook for tomcat application deployment. Apart from starting tomcat everything works without any issues. When i use startup.sh it works but i need to start tomcat with catalina.sh script.

   - name: start tomcat
     command: ./bin/catalina.sh start
     args:
       chdir: /websrv/tomcat/tomcat-8080/

This is what i am trying to do, it says started but it was never started.

TASK [start tomcat] ************************************************************
changed: [appserver.example.com]

Please help.

Note: I am using zipped version of tomcat on centos and have not installed tomcat. So if anyone shed light on how to start the script it would be really helpful.

Upvotes: 4

Views: 7243

Answers (3)

Lucifer7669
Lucifer7669

Reputation: 1

- name: tomcat-server
  service:
            name: tomcat
            state: started

Upvotes: 0

SilleBille
SilleBille

Reputation: 639

If you want a quick solution to run tomcat server unattached from Ansible's TTY use the following:

- name: "Starting Apache server"
  command: nohup {{ apache_install_location }}/tomcat9/bin/startup.sh

Upvotes: 8

nitzmahone
nitzmahone

Reputation: 13940

The built-in Tomcat management scripts don't detach from the tty, which causes them to be killed when the Ansible ssh session ends. You need to either hack the script to cause it to be backgrounded/detached, or write and install a proper init/systemd script (or crib from any of the numerous examples out there) for Tomcat. For example, here or here or here...

Upvotes: 5

Related Questions