How can you use a Chef recipe to set an environment variable?

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:load RAILS_ENV=#{rails_env}” environment ‘HOME’ => … Read more

Overriding attributes in the recipe

default.nginx_upstreams is the same as default[:nginx_upstreams] and default[‘nginx_upstreams’] – the convention is to use 1 of the latter two. And as you are using strings further, use them here too. The way you init nginx_upstreams in attribute file is the same as doing it this way: default[‘nginx_upstreams’][‘service1’] = [‘service1.server.com’] default[‘nginx_upstreams’][‘service2’] = [‘service2.server.com’] And you don’t … Read more