2013-07-12 2 views
8

こんにちは私はwcsユーザー(webadmin)を使用してcreate instanceコマンドを実行しなければならないWCSインスタンスを作成しています。必要なenv変数を取得できません。シェフが特定のユーザーと実行してその環境の値をロードする方法

ので私は私が

WebAdminのユーザー

を取得していますwhoamiをするために以下のコード

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 

を使用しています

をチェックするためにいくつかのサンプルコードを置きます

しかし、env私はgeですユーザー "root"のenvを照合し、env変数のための.bash_profileを提供しません。任意のアイデア

答えて

6

bash resourceにはenvironmentという属性があります。または、スクリプト内の.bash_profileをソースすることもできます。それはone of the things you can do with bashです(最後の例)

+0

が動作しようとしましたが、設定するにはかなりの環境変数があるので、bashリソースでコマンドを実行している間に設定するのは非常に面倒です。 – Saurav

+1

私は何か間違っているようですが、Pauloが提案した解決策は正しいです、私はソースを.bash_profile(今回は正しく)していて、うまくいきました。ありがとうございました – Saurav

+0

@ Sauravあなたはあなたが.bash_profileを適切に供給したと言いました。どうやって教えてくれますか?でも私はbash_profileを調達することに問題があります。 –

関連する問題