# Using web\_app

**URL:** <https://discourse.chef.io/t/using-web-app/2181>\
**Category:** Chef Infra (archive)\
**Created:** [November 14, 2011, 6:28pm UTC](https://discourse.chef.io/t/using-web-app/2181 "2011-11-14T18:28:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Smith](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@Brian\_Smith](https://discourse.chef.io/u/Brian_Smith)\
**Post date:** [November 14, 2011, 6:28pm UTC](https://discourse.chef.io/t/using-web-app/2181/1 "2011-11-14T18:28:00Z")

</div>

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](http://vbox.domain.com)"  
set #{node[:apache][:server\_aliases]} = ["[vbox1.domain.com](http://vbox1.domain.com) " ]  
when "Development"  
set #{node[:apache][:server\_name]} = "[dev.domain.com](http://dev.domain.com)"  
set #{node[:apache][:server\_aliases]} = ["[dev1.domian.com](http://dev1.domian.com) " ]  
else  
set #{node[:apache][:server\_name]} = "[fail.domain.com](http://fail.domain.com)"  
set #{node[:apache][:server\_aliases]} = ["[fail1.domain.com](http://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?
