Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
Created July 30, 2013 16:36
Show Gist options
  • Save nelsonsar/6114613 to your computer and use it in GitHub Desktop.
Save nelsonsar/6114613 to your computer and use it in GitHub Desktop.
Your own apache virtual host configuration with puppet
class apache {
package { "apache2":
ensure => present
}
service { "apache2":
enable => true,
ensure => running,
require => Package["apache2"]
}
}
<VirtualHost *:80>
ServerName <%= domain %>
ServerAdmin admin@<%= domain %>
DocumentRoot <%= docroot %>
ErrorLog ${APACHE_LOG_DIR}/<%= domain %>.error_log
CustomLog ${APACHE_LOG_DIR}/<%= domain %>.access_log common
<Directory /var/www/<%= domain %>>
Allow from all
Options +Includes +Indexes +FollowSymLinks
AllowOverride all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
define apache::vhost ($docroot, $domain, $vhost_name) {
include apache
file { "/etc/apache2/sites-available/${vhost_name}.conf":
content => template("apache/vhost.erb"),
notify => Exec["enable-${vhost_domain}-vhost"],
}
exec { "enable-${vhost_domain}-vhost":
command => "/usr/sbin/a2ensite ${vhost_name}.conf",
require => [ File["/etc/apache2/sites-available/${vhost_name}.conf"], Package["apache2"] ],
refreshonly => true,
notify => Service["apache2"],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment