Hi,
I am a novice to ansible and am practising to get more hands-on. I am
trying one usecase where I need to connect to a remote SLES12 linux server
using my id and then switch to root user and execute some tasks. While
switching over to root user (*cmd: *sudo rootsh), it prompts for a root
password. When I run this usecase using ansible playbook, it gives the
below error.

Could you please let me know what would be correct/valid directives
(become_*) that I need to use to run the cmd using root user. Appreciate
your help.

I wrote this playboo


*testroot.yaml*
---
- hosts: '{{ host }}'
  gather_facts: yes
  tasks:
    - name: Get current user on remote
      ansible.builtin.shell: |
        whoami
      become: true
      become_exe: "sudo rootsh"
      register: out
    - debug:
        msg: "{{ out }}"


*ansible-playbook -i hosts testroot.yaml -e "host=host.iil.corp.com
<http://host.iil.corp.com>" --ask-become-pass -k*
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
controller starting with Ansible 2.12. Current version: 3.6.15 (default,
Sep 15 2021, 14:20:42) [GCC]. This feature will be removed
from ansible-core in version 2.12. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.

*SSH password:BECOME password[defaults to SSH password]:*

PLAY [host.iil.corp.com]
********************************************************************************************************************************************************************************

TASK [Get current user on remote]
***************************************************************************************************************************************************************************
fatal: [host.iil.corp.com]: FAILED! => {"msg": "Timeout (12s) waiting for
privilege escalation prompt: Subject to Company's Global Employee and
Global Contingent Worker Privacy Notices\r\n(see
https://employeecontent.corp.com/content/corp/Global_Employee_and_Global_Contingent_Worker_Privacy.html
)\r\nall system access and delegated/privileged activity on the corp
network\r\nmay be logged for auditing and security purposes, including your
username \r\nand commands used.   Log records may be retained for up to 1
year.\r\n\r\nWe trust you have received the usual lecture from the local
System\r\nAdministrator. It usually boils down to these three
things:\r\n\r\n    #1) Respect the privacy of others.\r\n    #2) Think
before you type.\r\n    #3) With great power comes great
responsibility.\r\n\r\nRemember you may use 'sudo -l' to review a list of
authorized commands.\r\n\r\n"}

PLAY RECAP
**************************************************************************************************************************************************************************************************
host.iil.corp.com     : ok=0    changed=0    unreachable=0    failed=1
 skipped=0    rescued=0    ignored=0

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAE7H9qqYyOWf0b94uuPrKUBDige8PwB6bAa%3DrPS9J49PY4wLoA%40mail.gmail.com.

Reply via email to