Skip to content

Instantly share code, notes, and snippets.

@johnfitzpatrick
Last active August 29, 2015 14:01
Show Gist options
  • Save johnfitzpatrick/38443f65a38578fdf77f to your computer and use it in GitHub Desktop.
Save johnfitzpatrick/38443f65a38578fdf77f to your computer and use it in GitHub Desktop.
Intermediate class cookbooks/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
action :install
end
service "httpd" do
action [ :enable, :start ]
end
# Disable the default virtual host
execute "mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled" do
only_if do
File.exist?("/etc/httpd/conf.d/welcome.conf")
end
notifies :restart, "service[httpd]"
end
# Iterate over the apache sites
search("apache_sites", "*:*").each do |site|
# Enable an Apache Virtualhost
apache_vhost site['id'] do
site_port site['port']
action :create
notifies :restart, "service[httpd]"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment