default_stack recipe comes with one virtual host already setup for you, but you may find yourself wanting to add your own. Reviewing the code for how the passenger vhost is setup is a great way to learn to do this for other virtual hosts.
First, we start with a new template in
# app/manifests/templates/example.vhost.erb <VirtualHost *:80> # interesting stuff goes here </VirtualHost>
app/manifests/application_manifest.rb we're going to create a new recipe. It will use this template to create a new site in
/etc/apache2/sites-available and then enable it.
# app/manifests/application_manifest.rb class ApplicationManifest < Moonshine::Manifest::Rails recipe :default_stack def example_vhost file '/etc/apache2/sites-available/example', :ensure => :present, :content => template('example.vhost.erb', binding), :alias => 'example_vhost', :require => package('apache2') a2ensite 'example', :require => file('example_vhost') end recipe :example_vhost end
Commit, push, and deploy this, and you'll see your new virtual host in action.