Score:0

Ansible: Pbrun not able to execute

in flag

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

Score:1
cz flag

I do not see that you have set become_method: pbrun anywhere. This is required.

Rajarshi Das avatar
in flag
I have added become_method: pbrun into the playbook but still getting error permission denied
Rajarshi Das avatar
in flag
if I have added become true and become_method: pbrun then
Rajarshi Das avatar
in flag
"module_stdout": "No user specified!\r\r\nSorry, your request is not allowed: No access configured on Request rejected by pbmasterd on .\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 127} I get this error
Michael Hampton avatar
cz flag
@RajarshiDas It looks like you don't have access, then. You should talk to the appropriate people in your company to get the correct access.
Rajarshi Das avatar
in flag
Thanks for comments but in manually I can able to access root through pbrun
Rajarshi Das avatar
in flag
Michael the solution is become_flags: 'sa'. I ran pbrun sa -u root but thanks for your help
Michael Hampton avatar
cz flag
@RajarshiDas You should tick your own answer because it contains the correct solution.
Score:0
in flag

The solution i have found is below

  become: "yes"
  become_method: "pbrun"
  become_user: "root"
  become_flags: "sa"

as we ran pbrun sa -u root

also do not forget to set ansible_become_pass into inventory file or --ask-become-pass

thanks

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.