Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scarolan/ba973165e67f107427ea to your computer and use it in GitHub Desktop.
Save scarolan/ba973165e67f107427ea to your computer and use it in GitHub Desktop.
cookbooks/apache/providers/vhost.rb
use_inline_resources
action :create do
# Set the document root
document_root = "/srv/apache/#{new_resource.site_name}"
# Add a template for Apache virtual host configuration
template "/etc/httpd/conf.d/#{new_resource.site_name}.conf" do
source "custom.erb"
mode "0644"
variables(
:document_root => document_root,
:port => new_resource.site_port
)
end
directory document_root do
mode "0755"
recursive true
end
# Add a template resource for the virtual host's index.html
template "#{document_root}/index.html" do
source "index.html.erb"
mode "0644"
variables(
:site_name => new_resource.site_name,
:port => new_resource.site_port
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment