I am actually not supposed to add or set anything on that server as it is a
production server. So setting environment is not an option for me.
I just need to know the java version using ansible so that it will help me
a lot in reducing the manual works of my teammates.
I tried out using the below playbook with "java -version" instead of "which
java" but this time also faced error.
---
- name: "checking the java version"
hosts: host
remote_user: c5115061
gather_facts: False
become: yes
become_user: idmspp
become_method: 'sudo'
tasks:
- name: which java
shell: java -version
# args:
# executable: /usr/java/
register: java
- debug: msg="{{ java }}"
FAILED! => {"changed": true, "cmd": "java -version", "delta":
"0:00:00.074380", "end": "2019-01-28 06:00:14.656299", "msg": "non-zero
return code", "rc": 127, "start": "2019-01-28 06:00:14.581919", "stderr":
"/bin/bash: java: command not found", "stderr_lines": ["/bin/bash: java:
command not found"], "stdout": "", "stdout_lines": []}
Can anyone help me in this?
Thanks,
Ruben
On Tuesday, 22 January 2019 20:35:06 UTC+5:30, 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
>
>
> - debug: msg="{{ java }}"
> ...
>
>
> and getting the below error.
>
> FAILED! => {"changed": false, "cmd": "/usr/java/ -c 'which java'", "msg":
> "[Errno 13] Permission denied", "rc": 13}
>
>
> this is what I execute..
>
>
> ansible-playbook -i hosts java.yml -vv --ask-become-pass
>
>
> I will have to login first using "myremoteuser" and then I have to change
> the user to "serveruser" and execute the above command.
>
> I am able to do this directly on server but not through ansible.
>
>
> Kindly help.
>
>
> Thanks in advance,
>
> Ruben
>
--
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/49dd72ca-39cc-4b49-afc7-8175ae380dc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.