unable to sudo su to another user and execute commands

74 views
Skip to first unread message

vish man

unread,
May 22, 2017, 10:19:13 AM5/22/17
to Ansible Project
Hi,

Thanks in advance for helping me.

my ladap user on production server  is "viman"
my sudo su user on production server   is "cassdb"

I am trying to execute commands as cassdb user like id, ps -ef|grep ..., 

but it gives error 

10.45.206.104 | FAILED! => {
    "changed": false,
    "failed": true,
    "module_stderr": "",
    "module_stdout": "\r\nSorry, user viman is not allowed to execute '/bin/sh -c echo BECOME-SUCCESS-uqhffxyayhqcqqdiouilnxxqumlcxobw; /usr/bin/python /tmp/ansible-tmp-1495268464.677336-247138043012258/command.py' as cassdb on TXN-cappblx042-03.prod.XXXY.com.\r\n",
    "msg": "MODULE FAILURE",
    "rc": 1
}


commands I used tried are 

ansible all -b -m shell -a 'id -a' --become-user=cassdb



cfg file is 




defaults]
inventory      = /Users/viman/inventory
remote_tmp     = /tmp
forks          = 5
poll_interval  = 15
sudo_user      = cassdb
ask_sudo_pass = True
ask_pass      = True
transport      = smart
remote_port    = 22
module_lang    = C
gathering = implicit
host_key_checking = False
sudo_exe = sudo
timeout = 10
remote_user = viman
module_name = shell
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
action_plugins     = /usr/share/ansible_plugins/action_plugins
callback_plugins   = /usr/share/ansible_plugins/callback_plugins
connection_plugins = /usr/share/ansible_plugins/connection_plugins
lookup_plugins     = /usr/share/ansible_plugins/lookup_plugins
vars_plugins       = /usr/share/ansible_plugins/vars_plugins
filter_plugins     = /usr/share/ansible_plugins/filter_plugins
fact_caching = memory
[privilege_escalation]
become_method='sudo'
become_user='cassdb'
[paramiko_connection]
[ssh_connection]
pipelining = True
scp_if_ssh = True
[accelerate]
accelerate_port = 5099
accelerate_timeout = 30
accelerate_connect_timeout = 5.0
accelerate_daemon_timeout = 30
[selinux]
[colors]
[diff]

Kai Stian Olstad

unread,
May 26, 2017, 2:11:26 PM5/26/17
to ansible...@googlegroups.com
On 20. mai 2017 10:33, vish man wrote:
> Hi,
>
> Thanks in advance for helping me.
>
> my ladap user on production server is "viman"
> my sudo su user on production server is "cassdb"
It's not possible to combine sudo with su in Ansible, you need to choose
one of them.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages