两种情况。我正在使用chef-client在节点上安装MYSQL:
1)在第一个场景中,我将其作为“sudo”运行:
sudo chef-client
[2/5/14 6:30:31 PM] xxxx : : xxx: * execute[ldconfig] action run
================================================================================
Error executing action `run` on resource 'execute[ldconfig]'
================================================================================
[2/5/14 6:30:41 PM] xxxx : : xxx: when I run again "chef-client" then it works
[2/5/14 6:30:48 PM] xxxx : : xxx: I was running as: sudo chef-client
[2/5/14 6:31:15 PM] xxxx : : xxx: Errno::ENOENT
-------------
No such file or directory - ldconfig
2)在第二种情况下,从同一起点重新创建上面的VM,它成功而没有任何错误:
sudo su -
chef-client
后一种情况是成功的,没有与ldconfig相关的错误。
因此,我很困惑为什么厨师 - 客户端的sudo命令不起作用,而第二个命令没有问题?
答案 0 :(得分:2)
这可能是你的shell环境中的一些东西。从su:
的手册页 -l Simulate a full login. The environment is discarded except for HOME, SHELL, PATH, TERM, and USER. HOME and SHELL are modified as
above. USER is set to the target login. PATH is set to ``/bin:/usr/bin''. TERM is imported from your current environment. The
invoked shell is the target login's, and su will change directory to the target login's home directory.
- (no letter) The same as -l.
运行su -
会抛弃您环境中的内容而sudo却没有。相反,它保留了一些关于ldconfig命令试图做什么的东西。