script module show job successed but the job is failed or not work

Hi Everybody,

I want to startup tomcat by script module . The running output show the script is successful at target machine but actually tomcat do not startup. I try same script by command module. I meet same issue. If I directly run the script at target machine, the tomcat can startup.
My ansible is 2.1.1.0, I want to know whether or not this is a bug?

Please see below for detail test steps. Thanks.

  1. Create a shell script for startuping tomat at ansible machine. File name is mytest.script
#! /usr/bin/bash
sh /opt/apache-tomcat-9.0.0.M11/bin/startup.sh

  1. Use script module to run the script. The output show “Tomcat started”, but the tomcat do not start actually.
[root@localhost ~]# ansible 192.168.1.162 -m script -a "/root/mytest.script" -k
SSH password: 
192.168.1.162 | SUCCESS => {
    "changed": true, 
    "rc": 0, 
    "stderr": "", 
    "stdout": "Using CATALINA_BASE:   /opt/apache-tomcat-9.0.0.M11\r\nUsing CATALINA_HOME:   /opt/apache-tomcat-9.0.0.M11\r\nUsing CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M11/temp\r\nUsing JRE_HOME:        /usr\r\nUsing CLASSPATH:       /opt/apache-tomcat-9.0.0.M11/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M11/bin/tomcat-juli.jar\r\nTomcat started.\r\n", 
    "stdout_lines": [
        "Using CATALINA_BASE:   /opt/apache-tomcat-9.0.0.M11", 
        "Using CATALINA_HOME:   /opt/apache-tomcat-9.0.0.M11", 
        "Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M11/temp", 
        "Using JRE_HOME:        /usr", 
        "Using CLASSPATH:       /opt/apache-tomcat-9.0.0.M11/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M11/bin/tomcat-juli.jar", 
        "Tomcat started."
    ]
}

In target machine, check the tomcat processer. not found.

[root@client ~]# ps aux | grep tomcat
root      5924  0.0  0.0 112648   976 pts/0    R+   11:27   0:00 grep --color=auto tomcat

  1. scp the script to the 192.168.1.162. Run it by command module and have same issue.
[root@localhost ~]# ansible 192.168.1.162 -m command -a "/usr/bin/bash /root/mytest.script" -k
SSH password: 
192.168.1.162 | SUCCESS | rc=0 >>
Tomcat started.

[root@client bin]# ps aux |grep tomcat
root      5980  0.0  0.0 112648   976 pts/1    R+   11:35   0:00 grep --color=auto tomcat

  1. Direclty run the mytest.script. Tomcat is startup.
[root@client ~]# /usr/bin/bash /root/mytest.script 
Using CATALINA_BASE:   /opt/apache-tomcat-9.0.0.M11
Using CATALINA_HOME:   /opt/apache-tomcat-9.0.0.M11
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M11/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-9.0.0.M11/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M11/bin/tomcat-juli.jar
Tomcat started.

[root@client ~]# ps aux |grep tomcat
root      5998  7.7  5.9 3154888 112408 pts/1  Sl   11:37   0:02 /usr/bin/java -Djava.util.logging.config.file=/opt/apache-tomcat-9.0.0.M11/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms1024m -Xmx1024m -XX:+UseG1GC -Datlassian.plugins.enable.wait=300 -Djava.awt.headless=true -Xloggc:/logs/gc-2016-12-05_11-37-34.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M -XX:-PrintGCDetails -XX:+PrintGCTimeStamps -XX:-PrintTenuringDistribution -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Djava.rmi.server.hostname=192.168.1.162 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.class.path=/usr/share/collectd/java/collectd-api.jar:/usr/share/collectd/java/generic-jmx.jar -classpath /opt/apache-tomcat-9.0.0.M11/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M11/bin/tomcat-juli.jar -Dcatalina.base=/opt/apache-tomcat-9.0.0.M11 -Dcatalina.home=/opt/apache-tomcat-9.0.0.M11 -Djava.io.tmpdir=/opt/apache-tomcat-9.0.0.M11/temp org.apache.catalina.startup.Bootstrap start
root      6032  0.0  0.0 112648   976 pts/1    R+   11:38   0:00 grep --color=auto tomcat

Thanks
Ray