Skip to content

Instantly share code, notes, and snippets.

@nathenharvey
Created September 23, 2013 17:13
Show Gist options
  • Save nathenharvey/6673845 to your computer and use it in GitHub Desktop.
Save nathenharvey/6673845 to your computer and use it in GitHub Desktop.
data_bag("vhosts").each do |site|
site_data = data_bag_item("vhosts", site)
site_name = site_data["id"]
document_root = "/srv/apache/#{site_name}"
template "/etc/apache2/sites-available/#{site_name}" do
source "custom-vhost.erb"
mode "0644"
variables(
:document_root => document_root,
:port => site_data["port"]
)
end
execute "a2ensite #{site_name}" do
not_if do
::File.symlink?("/etc/apache2/sites-enabled/#{site_name}")
end
notifies :restart, "service[apache2]"
end
directory document_root do
mode "0755"
recursive true
end
template "#{document_root}/index.html" do
source "index.html.erb"
mode "0644"
variables(
:site_name => site_name,
:port => site_data["port"]
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment