Chef open source server v11.1.7
I am aware I can manually set environment variables that are persistent throughout the chef-client run via
ENV[‘FOO’] = ‘bar’
I have a requirement in my chef automation to source multiple environment variables by sourcing a shell script.
This setEnv script sets various environment variables and also internally invokes further shell scripts which set even more environment variables, all of which are required for the subsequent command to run properly.
Is there a way I can set environment variables in a recipe by sourcing from a shell script instead of having to manually set each environment var one by one? (which sometimes I don’t even know the values because the setENV script is dynamically calculating the env values)
e.g. what i would like to do:
<step 1 - set various environment variables *by sourcing from a shell script*> <step 2 - run chef resources which require all the env vars set in step 1>