Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created October 17, 2011 20:29
Show Gist options
  • Save jtimberman/1293701 to your computer and use it in GitHub Desktop.
Save jtimberman/1293701 to your computer and use it in GitHub Desktop.
goes in chef-repo/data_bags/apache/
{
"id": "stuff",
"admin_address": {
"_default": "noone@example.com",
"production": "root@example.com",
"development": "devs@example.com",
}
}
<VirtualHost *:80>
# bunch of config!
ServerAdmin <%= @server_admin %>
# Other config!
</VirtualHost>
# selecting the address from the data bag by environment
apache_stuff = data_bag_item("apache", "stuff")
template "/etc/apache2/sites-available/my_vhost.conf" do
source "my_vhost.conf.erb"
variables(:server_admin => apache_stuff['admin_address'][node.chef_environment])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment