8
嗨,我正在創建一個WCS實例,爲此我必須使用wcs用戶(webadmin)執行create instance命令,其未能連接到數據庫它無法獲得所需的env變量。如何讓廚師執行特定用戶並加載其環境值
,所以我把一些示例代碼來檢查
我使用下面的代碼
bash "wcs-create-instance" do
user "webadmin"
group "webspher"
code <<-EOH
###{node[:websphere][:wcs][:wcs_installLocation]}/bin/config_ant.sh -DinstanceName=#{node[:websphere][:wcs][:wcs_instance]} CreateInstance
whoami > /tmp/whoami
env > /tmp/env
EOH
notifies :run, "bash[fix-permission]", :immediately
#This not_if is just temporary, a proper mechanism has to be implemented here to loop through all the WCS APars,
#For the POC keeping it neat and simple such that this does not rerun on execution
not_if {File.directory?("#{node[:websphere][:wcs][:wcs_installLocation]}/instances/#{node[:websphere][:wcs][:wcs_instance]}/starterstores")}
#action :nothing
end
對於WHOAMI我得到用戶
WebAdmin的
但是對於env我是ge將用戶的環境設置爲「root」,其不爲env變量提供.bash_profile。任何想法
試圖源,但它不工作,因爲有相當多的環境變量設置,設置它,而在bash資源中運行命令將是非常繁瑣的。 – Saurav
似乎我做錯了什麼,Paulo提出的解決方案是正確的,我確實源自.bash_profile(這次正確),它工作正常。再次感謝 – Saurav
@Saurav你提到你正確的源自.bash_profile。你能告訴我如何?即使我面臨採購bash_profile –