How can you use a Chef recipe to set an environment variable?
问题 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? 回答1: 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: execute 'Bootstrap the database' do cwd "#{app_dir}/current" command "#{env_cmd} rake db:drop db:create db:schema