9

こんにちは、WCS インスタンスを作成しています。wcs ユーザー (webadmin) を使用して create instance コマンドを実行する必要があります。必要な環境変数を取得できないため、DB に接続できません。

だから私はチェックするためにいくつかのサンプルコードを入れました

以下のコードを使用しています

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 については、ユーザー「root」の env を取得していますが、env 変数の .bash_profile を取得していません。何か案は

4

2 に答える 2

-1

flags '-l'ログインシェルとして機能するようにbashに指示するために追加することも、そのトリックを行うようです。

bash 'do something' do
  code 'my_command'
  flags '-l'
end

またはexecuteブロックを使用して:

execute 'foo' do
  command 'bash -l -c "my_command"'
end
于 2019-05-21T00:40:56.543 に答える