简体   繁体   中英

Unable to run java jar command on target machine in Ansible

I am trying to run the following command:

java -jar jar-from-application.jar --file myown.properties

Couple of problems I faced earlier while trying to run this on target machine. Tomcat needs to be running and a war file needs to be deployed completely before I run the above command. This is what I did to insure that pre conditions are met. For Tomcat:

nohup startup.sh

and then check for deployed file bu using curl to check for status 200:

- name: Check if URL is available
  shell: curl --head --silent http://target-mchine:8080/restoftheurl
  register: result
  until: result.stdout.find("200 OK") != -1
  retries: 12
  delay: 10

It does above two steps correctly but when the next task is to run the

java -jar jar-from-application.jar --file myown.properties

it for some reason says that it cannot read the properties file. However, if I run the same jar command on the remote machine locally, then it works perfectly. I even added some wait time after successful execution of curl command, just in case, but it doesn't make any difference. I tried doing the following too:

nohup java -jar jar-from-application.jar --file myown.properties

as it was suggested online but that didn't make any difference either. Any suggestions will be appreciated. Thank You.

确保使用命令模块chdir参数在命令中为属性文件设置了正确的path ,或者在命令中设置了完整路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM