gpt4 book ai didi

Ansible:考虑使用 'become' 、 'become_method' 和 'become_user' 而不是运行 sudo

转载 作者:行者123 更新时间:2023-12-01 00:16:04 25 4
gpt4 key购买 nike

当我运行这个:
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 等效于什么为 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
}

附言Ansible 版本:2.6.4

最佳答案

我必须指定 --become_method su .或者更具体地说 ansible host -u myuser --become-method su --become-user otheruser -a "/bin/echo hello"
附言我路过-a "/bin/echo hello" ,因为 ansible 期望在更改用户后运行一些命令。

关于Ansible:考虑使用 'become' 、 'become_method' 和 'become_user' 而不是运行 sudo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52456641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com