Ansible - how to run Java jar with parameters?
14,346
Run below commands on your target server to rule out Java issues
which java
java -version
Upon successful results add quotes to your shell command like below and run the playbook again.
shell: "java -jar Installer20161018.jar -readImage Linux_x86-64_20161111.zip -installDir /opt/installPath/vf5511/instDir"
Author by
Zibi Smough
Updated on June 04, 2022Comments
-
Zibi Smough almost 2 years
I have a problem with ansible playbook. I am trying to run a Java jar as a command. Whenever I run this directly on the virtual machine - it works all the time:
java -jar Installer20161018.jar -readImage Linux_x86-64_20161111.zip -installDir /opt/installPath/vf5511/instDir
important information: the installation HAS to be run from user
vf5511
, and hishome
folder is/opt/installPath/vf5511
But when trying to write a playbook and run it - it gets all wrong.
This is the playbook:
--- - hosts: webmwc10 become: yes become_user: wm5511 become_method: sudo tasks: - name: installing server shell: java -jar Installer20161018.jar -readImage Linux_x86-64_20161111.zip -installDir /opt/installPath/vf5511/instDir
When I run the playbook, I get an error:
"rc": 127, "start": "2017-06-02 09:21:31.931049", "stderr": "/bin/sh: java: command not found", "stderr_lines": [ "/bin/sh: java: command not found" ], "stdout": "", "stdout_lines": []
Java not found? I don't understand this. Java is installed and working properly!
Can anyone help me with this?
-
harshavmb almost 7 yearsThis would work as a check before running jar, but the question is targeted more at running jar.