Using web_app


#1

I would like to use the web_app definition to deploy multiple apache vhosts
on a system and change the prefix depending on the environment.
I am thinking to do something like this, I set the attributes file as such:

case #{node[:app_environment]}
when "VirtualBox"
set #{node[:apache][:server_name]} = "vbox.domain.com"
set #{node[:apache][:server_aliases]} = [ "vbox1.domain.com " ]
when "Development"
set #{node[:apache][:server_name]} = "dev.domain.com"
set #{node[:apache][:server_aliases]} = [ "dev1.domian.com " ]
else
set #{node[:apache][:server_name]} = "fail.domain.com"
set #{node[:apache][:server_aliases]} = [ "fail1.domain.com " ]
end

And then do something like this as the recipe:

web_app “#{node[:apache][:server_name]}” do
enable :true
server_name "#{node[:apache][:server_name]}"
server_aliases "#{node[:apache][:server_aliases]}"
docroot "/var/www/#{node[:apache][:server_name]}"
template "web_app.conf.erb"
cookbook "apache2"
mode "0644"
notifies :restart, resources(:service => “apache2”)
end

Anyone doing something like this in a working cookbook definition?