当我运行这个:
ansible host -u myuser -a "sudo su - otheruser -s /bin/bash"
我收到警告:
[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather
than running sudo
host | SUCCESS | rc=0 >>
但是使用become
for什么是等效的sudo su - otheruser -s /bin/bash
?
我试过:
ansible host -u myuser --become --become-user otheruser -a "/bin/echo hello"
但我得到:
host | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to host closed.\r\n",
"module_stdout": "sudo: a password is required\r\n",
"msg": "MODULE FAILURE",
"rc": 1
}
PS Ansible 版本:2.6.4