Skip to content

Instantly share code, notes, and snippets.

@nathenharvey
Last active May 31, 2016 16:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nathenharvey/9134977 to your computer and use it in GitHub Desktop.
Save nathenharvey/9134977 to your computer and use it in GitHub Desktop.
vhosts recipe for one-day Introduction to Chef workshop
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/httpd/conf.d/#{site_name}.conf" do
source "custom-vhosts.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"
mode "0644"
variables(
:site_name => site_name,
:port => site_data["port"]
)
end
end
@SadafP
Copy link

SadafP commented May 30, 2016

Hi,

I have been following tutorial for chef and could see this code into the tutorial by Nathen, Can anyone explain this code please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment