How to execute a backend java program?

Hi,
I use ansible 2.0.0. and I want start a java web program which use spring boot and compile as a jar file, but it always don’t work.
I can execute “nohup java -jar xxx.jar &” on the target machine (the target machine is centos 7),but when I execute through ansible, it don’t work.
my playbook is

`

  • hosts: testservers
    remote_user: root
    tasks:
  • name: start product
    shell: chdir=/app nohup java -jar /app/product.jar &

`

I think all the method I can , for example, make a .sh file in the target machine, the sh file is

`

#!/bin/bash
java -jar /app/product.jar > /dev/null 2>&1

`
and I execute the sh file , it can start .
and the playbook is

`
shell: chdir=/app nohup ./startproduct.sh &

`
and I execute the playbook,
the product.jar can not be started yet.

and then I add it to service, the file is

`

#!/bin/bash

Hello, !
(Sorry can’t spell your name).

Try this working example:

`

  • name: Start jenkins
    remote_user: “{{jenkins_owner_user}}”
    shell: cd {{jenkins_home_path_bin}}/ && nohup java -Djenkins.install.runSetupWizard=false -Dhudson.diyChunking=false -DJENKINS_HOME={{jenkins_home_path_data}} -jar ./jenkins.war --httpPort={{jenkins_port}} &
    async: 45
    poll: 0

`