title: Ansible - how to run Java jar with parameters?
body: <p>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:</p>
  
  <pre><code>java -jar Installer20161018.jar -readImage Linux_x86-64_20161111.zip -installDir /opt/installPath/vf5511/instDir
  </code></pre>
  
  <p><strong>important information:</strong> the installation HAS to be run from user <code>vf5511</code>, and his <code>home</code> folder is <code>/opt/installPath/vf5511</code></p>
  
  <p>But when trying to write a playbook and run it - it gets all wrong.</p>
  
  <p>This is the playbook:</p>
  
  <pre><code>---
  - 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
  </code></pre>
  
  <p>When I run the playbook, I get an error:</p>
  
  <pre><code>"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": []
  </code></pre>
  
  <p>Java not found? I don't understand this. Java is installed and working properly!</p>
  
  <p>Can anyone help me with this?</p>