Ansible: Pbrun not able to execute
I have the below inventory file
[server]
abc.com
[server:vars]
ansible_user="user1"
ansible_ssh_pass="pwd"
ansible_pbrun_exe="pbrun"
ansible_pbrun_password="pqa"
ansible_pbrun_user="root"
and the playbook file
---
- name: Upgrade Java Version to all the hosts
hosts: all
tasks:
- name: run simple command
shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
register: javav
- name: remove the currently installed java
become: true
become_method: "pbrun"
shell: |
mv /usr/bin/java ~/bckup_java_exe
mv /usr/java/ ~/bckup_java
Now when I run the ansible playbook it connects to the ssh host and is also able to run the java -version ..
command successfully but not able to run the mv
command as it needs pbrun
when I remove become: true
from playbook it shows Permission error
```
: Permission denied", "mv: cannot move `/usr/java/' to
````
And when I do not remove become: true
it gives some other error, and it is not working either
I do not see that you have set become_method: pbrun
anywhere. This is required.