It looks as if it's working. It is running the command "which java". The "which" command is unable to find an executable called "java" in the path, so it outputs an appropriate message to stderr and returns a non zero value.
It looks as if you are trying to locate the java executable, but that will only work if the executable is in the shell's PATH. If you know what to add to the PATH variable, you probably no longer need to use which to find java :-) If you know roughly where it is, e.g., under /usr somewhere, you could use find to locate it: find -L /usr -executable -type f -name "java" -print But to be honest, if you will be running java, you probably need to know exactly which executable you should be running. Otherwise you will have to run a battery of tests to make sure that the executable you find is the right executable (version, architecture etc) Regards, K. On Thu, Jan 24, 2019 at 12:45 AM ruben melvin <[email protected]> wrote: > I tried removing the args and executable, then while trying to execute > again I am getting an error below. > > {"changed": true, "cmd": "which java", "delta": "0:00:00.074712", "end": > "2019-01-23 13:41:10.748039", "msg": "non-zero return code", "rc": 1, > "start": "2019-01-23 13:41:10.673327", "stderr": "which: no java in > (/usr/bin:/bin:/usr/sbin:/sbin)", "stderr_lines": ["which: no java in > (/usr/bin:/bin:/usr/sbin:/sbin)"], "stdout": "", "stdout_lines": []} > > Kindly help. > Ruben > > On Wednesday, 23 January 2019 02:06:43 UTC+5:30, Kai Stian Olstad wrote: >> >> On Tuesday, 22 January 2019 16:05:06 CET ruben melvin wrote: >> > Hi guys, >> > >> > I am trying to execute below ansible playbook. >> > >> > --- >> > - name: "checking the java version" >> > hosts: host >> > remote_user: myremoteuser >> > gather_facts: False >> > become: yes >> > become_user: serveruser >> > become_method: 'sudo' >> > >> > tasks: >> > - name: which java >> > shell: which java >> > args: >> > executable: /usr/java/ >> > register: java >> >> Here you are trying to run the directory /usr/java/ >> just remove the args and executable and it should work. >> >> >> -- >> Kai Stian Olstad >> >> >> -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/527b1756-839f-4b6d-9660-ee6745f7aa71%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/527b1756-839f-4b6d-9660-ee6745f7aa71%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Karl Auer Email : [email protected] Website: http://2pisoftware.com GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816 Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Qo9w3itrPuW4yJMYdQDntw4mv2Nk2Jd8SWfwCO%2B46%2BCw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
