在执行特殊命令或玩游戏时,我遇到了一种情况,环境变量来自
/home/user-that-sudoed/.bashrc
需要读取临时命令或剧本才能在目标清单主机上工作。在里面
.bashrc
文件我们有设置
LD_LIBRARY_PATH
(对于我们使用的一些python函数是必需的)。
中是否有参数
/home/local-user/.ansible.cfg
这能有效地扭转局面”
/bin/sh -c
“入”
/bin/sh
“不”
-c
“?“
-C
“(命令运行在下面)。
ssh -q -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/tmp/.ansible/sockets/5c2164546a zlpv1229 '/bin/sh -c '"'"'sudo -H -S -n -u atg /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-cyhlvtntyqmbkkmcpkhhkspusdirgwlk; /sites/utils/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
连接方式为“
user@controller
到
user@inventory_host
然后
用户@inventory_主机
正在成为
user-that-sudoed
’