'switch to oracle user from root using su method - timeout (62s) waiting for privilege escalation prompt
I'm able to ssh
to an oracle server manually without password, sudo
to root and then su
to oracle user. The same I'm trying to do with ansible, but getting timeout (62s) waiting for privilege escalation prompt
with su
to oracle user.
Manual
[testuser@ansibleServer ans_playbook]$ ssh ansibleUser@server1
-bash: TMOUT: readonly variable
[ansibleUser@server1 ~]$ sudo su - root
Last login: Wed Mar 9 15:45:36 IST 2022 on pts/1
-bash: TMOUT: readonly variable
[root@server1 ~]# su - oracle
Last login: Wed Mar 9 18:14:34 IST 2022
-bash: TMOUT: readonly variable
server1:MAMO1:oracle:/home/oracle>pwd
/home/oracle
server1:MAMO1:oracle:/home/oracle>exit
logout
[root@server1 ~]# exit
logout
[ansibleUser@server1 ~]$ exit
logout
Connection to server1 closed.
[testuser@ansibleServer ans_playbook]$
Ansible
---
- name: "playbook for oracle operation"
hosts: "{{ hostname }}"
gather_facts: false
ignore_errors: true
become: yes
tasks:
- name: Gather facts
setup:
gather_subset: facter
- name: Get oracle user
shell: ps -ef|grep ora_pmon | grep -v 'grep'| awk '{print $1}'
register: user_name
- name: get user name
set_fact:
user: "{{ user_name.stdout|regex_replace( '(\\w+).*','\\1' ) }}"
when: user_name.rc == 0
- name: operation
shell: |
export ORACLE_SID={{ orasid }}; ORAENV_ASK=NO;. oraenv;
rman target / <<EOF
list archivelog all;
EOF
register: archivelog
become: true
become_method: su
become_flags: "--login"
become_user: "{{ user }}"
Error
With operation task getting the below error. Tried without --login
, but failed with same error.
timeout (62s) waiting for privilege escalation prompt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|