Skip to content

Instantly share code, notes, and snippets.

@someara
Forked from adamhjk/default.rb
Created June 19, 2012 03:41
Show Gist options
  • Save someara/2952172 to your computer and use it in GitHub Desktop.
Save someara/2952172 to your computer and use it in GitHub Desktop.
Re-factored Apache cookbook
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2012, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
action :install
end
cookbook_file "/var/www/html/index.html" do
source "index.html"
mode "0644"
end
node['apache']['sites'].each do | site_name, site_data |
document_root = "/srv/apache/#{site_name}"
template "/etc/httpd/conf.d/#{site_name}.conf" do
source "custom.erb"
mode "0644"
variables(
:document_root => document_root,
:port => site_data['port']
)
notifies :restart, 'service[httpd]'
end
directory document_root do
mode "0755"
recursive true
end
template "#{document_root}/index.html" do
source "index.html.erb"
variables(
:site_name => site_name,
:port => site_data['port']
)
mode "0644"
end
end
service "httpd" do
action [:start, :enable]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment