I finally solved it by using the script from the ansible 
examples: 
https://github.com/ansible/ansible-examples/blob/master/tomcat-standalone/roles/tomcat/files/tomcat-initscript.sh

On Thursday, February 13, 2014 12:48:22 AM UTC+1, Will Thames wrote:
>
> This came up for me in the past. I found setsid pretty helpful too
>
> https://github.com/ansible/ansible/pull/4800
>
> (note that #4800 never amounted to much as it caused too many other 
> problems, but the workaround still applies!)
>
> Will
>
> On Wednesday, February 12, 2014 4:58:42 AM UTC+10, Alain Sahli wrote:
>>
>> Thank you very much! Your solution works.
>>
>> On Tuesday, February 11, 2014 5:27:50 PM UTC+1, David Adams wrote:
>>>
>>> This is a good point. Tomcat does NOT detach, so running startup.sh 
>>> directly from an Ansible ssh session may well immediately shut down. You've 
>>> got to wrap it in something that will detach correctly. The easiest would 
>>> be nohup. startup.sh is also kind of pointless. You can just call 
>>> catalina.sh directly. From my Tomcat app's init script:
>>>
>>>     nohup $CATALINA_HOME/bin/catalina.sh start
>>>
>>> -dave
>>>
>>>
>>>
>>> On Tue, Feb 11, 2014 at 6:50 AM, Karl E. Jorgensen <
>>> [email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> On Sun, Feb 09, 2014 at 12:25:06PM -0800, Alain Sahli wrote:
>>>> > Hi!
>>>> >
>>>> > I wrote a simple playbook that downloads, extracts and starts Tomcat. 
>>>> Here are
>>>> > the relevant parts of it:
>>>> >
>>>> > - name: Download Tomcat 7.0.42
>>>> >   get_url: url=
>>>> http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.42/bin/
>>>> > apache-tomcat-7.0.42.tar.gz 
>>>> dest=/home/tomcat/apache-tomcat-7.0.42.tar.gz
>>>> >
>>>> > - name: Extract Tomcat
>>>> >   command: chdir=/home/tomcat tar -xvzf apache-tomcat-7.0.42.tar.gz 
>>>> creates=/
>>>> > home/tomcat/apache-tomcat-7.0.42
>>>> >
>>>> > - name: Change ownership of Tomcat installation
>>>> >   file: path=/home/tomcat/apache-tomcat-7.0.42 owner=tomcat 
>>>> group=tomcat state=
>>>> > directory recurse=yes
>>>> >
>>>> > - name: Configure Tomcat server
>>>> >   template: src=tomcat-users.xml 
>>>> dest=/home/tomcat/apache-tomcat-7.0.42/conf/
>>>> >   notify: restart tomcat
>>>> >
>>>> > - name: Set JAVA_HOME for tomcat
>>>> >   lineinfile: dest=/home/tomcat/apache-tomcat-7.0.42/bin/setenv.sh 
>>>> line='export
>>>> > JAVA_HOME=/opt/java/jdk1.7.0_51' create=yes state=present mode=0555
>>>> >
>>>> > - name: Start Tomcat
>>>> >   command: /home/tomcat/apache-tomcat-7.0.42/bin/startup.sh
>>>> >   sudo: true
>>>> >   sudo_user: tomcat
>>>> >
>>>> > - name: wait for tomcat to start
>>>> >   wait_for: port=8080
>>>>
>>>> Does tomcat actually detach from the TTY?
>>>>
>>>> IIRC failure to do so can keep the SSH session open. Or alternatively:
>>>> Break the offending process (tomcat) when ssh is killed...
>>>>
>>>> If you start tomcat from a normal login shell, and run "ps -ef|grep
>>>> tomcat" (or similar), it should not be associated with your login
>>>> tty...
>>>>
>>>> --
>>>> Karl E. Jorgensen
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to