Unable to used the PBRUN command in Ansible

82 views
Skip to first unread message

Shtrudhan Kumar

unread,
Sep 28, 2021, 6:30:42 AM9/28/21
to Ansible Project
Hi Team,
i am new in Ansible. i have installed the Ansible core and my environment used pbrun bash to give the privallage access to the server and want to use the same in Ansible playbook. Could you guide me how to used this. This is urgent.

Regards
Shtrudhan Kumar

Dick Visser

unread,
Sep 28, 2021, 8:45:55 AM9/28/21
to ansible...@googlegroups.com
I don't see any playbook, or other content.
What did you try already?
What are you trying to automate?

On a side note, if you are new to ansible, what is the urgency about? 


--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ca31484c-7e31-46a1-abe7-9a4b22484e2bn%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Message has been deleted

Dick Visser

unread,
Sep 28, 2021, 10:07:55 AM9/28/21
to ansible...@googlegroups.com
I meant what does DISTRIB_CODENAME evaluate to on the target system?


On Tue, 28 Sep 2021 at 14:49, 'Neil Young' via Ansible Project <ansible...@googlegroups.com> wrote:
There is no urgency. I just tested your 3 liner, which doesn't work as a replacement to the other solution.

Works (but is verbose and is of course correctly indented in reality, just not here):

 - name: Install Kurento Media Server - Import the Kurento repository signing key
ansible.builtin.shell: |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
- name: Install Kurento Media Server - Get Ubuntu version definitions and add repository to apt
ansible.builtin.shell: |
source /etc/lsb-release
tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <<EOF
# Kurento Media Server - Release packages
deb [arch=amd64] http://ubuntu.openvidu.io/6.16.0 $DISTRIB_CODENAME kms6
EOF
args:
executable: /bin/bash

- name: Install Kurento Media Server - Full install (takes time)
ansible.builtin.shell: |
apt-get update && apt-get install --no-install-recommends --yes kurento-media-server


Does not work:

 - name: Install Kurento Media Server - Import the Kurento repository signing key
ansible.builtin.shell: |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83

- name: Install Kurento Media Server
ansible.builtin.apt_repository:
repo: "[arch=amd64] http://ubuntu.openvidu.io/6.16.0 {{
ansible_distribution_release }} kms6"
filename: kurento


Neil Young

unread,
Sep 28, 2021, 10:08:18 AM9/28/21
to Ansible Project
"bionic" . All fine

Dick Visser

unread,
Sep 28, 2021, 11:03:52 AM9/28/21
to ansible...@googlegroups.com
Ha ok tiny hiccup. 
Glad it works.
And in 3 lines!

Shtrudhan Kumar

unread,
Sep 29, 2021, 5:30:02 AM9/29/21
to Ansible Project
Thank you,
---
- hosts: all
  tasks:
    - name: stop a service
      become_method: pbrun
      shell: /opt/tomcat/apache-tomcat-7.0.29/bin/shutdown.sh
      register: output
    - debug:
        msg: "{{ output }}"

Below is output while running the playbook.
ansible-playbook service.yml -vvv
.startup.Bootstrap.main(Bootstrap.java:453)",
        "stderr_lines": [
            "Sep 29, 2021 9:23:15 AM org.apache.catalina.startup.Catalina stopServer",
            "SEVERE: Catalina.stop: ",
            "java.io.FileNotFoundException: /opt/tomcat/apache-tomcat-7.0.29/conf/server.xml (Permission denied)",
            "\tat java.io.FileInputStream.open(Native Method)",
            "\tat java.io.FileInputStream.<init>(FileInputStream.java:140)",
            "\tat org.apache.catalina.startup.Catalina.stopServer(Catalina.java:458)",
            "\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",

On the server, i have access of pbrun bash and can be run the command. 
how i am doing in target node. First login to server using my credential and then running the command pbrun bash and then i can run the /opt/tomcat/apache-tomcat-7.0.29/bin/shutdown.sh
it run successful.

Regards
Shtrudhan Kumar



Gildas Cotomale

unread,
Oct 8, 2021, 2:02:40 AM10/8/21
to Ansible Project
Hello,

First, are you using the same account with the playbook and when you test interactively ?
And are you sure you are using the same "become_user" ?

Second, when your playbook run a task/module, it is using a clean minimal environment ?
Are you able to issue the same command in non interactive mode ? (for example from a cron/at/...)

If you have to do "pbrun bash" then the command, it's not exactly the same as doing "pbrun thecommand" (what you are asking your playbook to do) You're first loading a specific interpreter (and I'm not sure your playbook is using the same exact shell) in interactive session (hence setting environment variables and doing stuffs via the ~/.bashrc or ~/.profile etc)

Just few hints.
Regards.


Reply all
Reply to author
Forward
0 new messages