Hi I am creating a WCS instance, for which i have to execute the create instance command using the wcs user (webadmin), its failing to connect to DB as its not able to get the required env variables.
so i put some sample code to check
I am using the below code
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
For whoami i am getting the user
webadmin
But for env i am getting the env of the user "root", its not sourcing the .bash_profile for the env variables. Any ideas
There is an
environment
attribute in thebash
resource. Or you can source the .bash_profile in the script. That's one of the things you can do with bash (last example)Seems like adding
flags '-l'
to tell bash to act as a login shell also does the trick.Or using the
execute
block: