How can you use a Chef recipe to set an environment variable?
I need to set an environment variable using a Chef recipe. Can you provide an example of how to accomplish this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you need an env var set strictly within the Chef process, you can use
ENV['foo'] = 'bar‘ since it’s a ruby process.If you need to set one for an execute provider, Chef exposes an environment hash:
If you’re looking to set a persistent environment variable then you may want to have Chef edit
/etc/profile.d/chef.sh,/etc/environment, a users’ profile, etc.