2013-07-12 2 views
8

안녕하세요, wcs 사용자 (webadmin)를 사용하여 인스턴스 작성 명령을 실행해야하는 WCS 인스턴스를 만들고 있는데, 해당 DB에 연결하지 못했습니다. 그것은 필요한 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 i는 ge입니다. 사용자 "루트"의 env를 tting하고, 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을 소싱하는 데 문제가 있습니다. –