2014-02-06 79 views
0

兩種情況。我使用的節點上安裝MYSQL廚師客戶端:在「sudo」命令下運行chef-client的問題vs「su」

1)在第一個場景我運行它作爲「命令」:

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

這都是關於環境。他們是根本不同的東西。 – sethvargo

回答

2

它可能是你的shell的環境中的東西。從蘇手冊頁:

-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 -拋出你的環境的內容,須藤沒有。相反,它保留了一些東西,拋出一些關於ldconfig命令試圖做的事情。