Created
July 30, 2013 16:36
-
-
Save nelsonsar/6114613 to your computer and use it in GitHub Desktop.
Your own apache virtual host configuration with puppet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class apache { | |
| package { "apache2": | |
| ensure => present | |
| } | |
| service { "apache2": | |
| enable => true, | |
| ensure => running, | |
| require => Package["apache2"] | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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