# # Puppet module for Apache # # This module is distributed under the GNU Affero General Public License: # # Backup module for puppet # Copyright (C) 2009 Sarava Group # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Using code from Debian Apache2 recipe: # # http://reductivelabs.com/trac/puppet/wiki/Recipes/DebianApache2Recipe # $apache2_sites = "/etc/apache2/sites" $apache2_mods = "/etc/apache2/mods" $apache2_conf_d = "/etc/apache2/conf.d" $apache2_macros = "/etc/apache2/conf.d/macros" $apache2_conf = "/etc/apache2/apache2.conf" class apache { include ssl case $apache_www_folder { '': { $apache_www_folder = "/var/www" } } case $apache_default_folder { # Give the "It works!" webpage by default. '': { $apache_default_folder = "/var/www" } } case $apache_sites_folder { '': { $apache_sites_folder = "${apache_www_folder}/sites" } } case $apache_error_folder { '': { $apache_error_folder = "${apache_www_folder}/error" } } case $apache_error_dest { '': { $apache_error_dest = "${apache_error_folder}/index.html" } } case $apache_server_name { '': { $apache_server_name = $hostname } } package { "apache": name => "apache2-mpm-itk", ensure => installed, } package { "mod_macro": name => "libapache2-mod-macro", ensure => installed, } service { "apache2": alias => "apache", ensure => running, require => Package["apache"], hasstatus => true, hasrestart => true, } module { "macro": ensure => present, require => Package["mod_macro"], } module { "headers": ensure => present, require => Package["apache"], } module { "ssl": ensure => present, require => Package["apache"], } module { "rewrite": ensure => present, require => Package["apache"], } # apache mod_macro configuration file { "${apache2_macros}": ensure => present, content => template('apache/macros.erb'), owner => root, group => root, mode => 0644, require => Module["macro"], notify => Service["apache"], } # apache mod_macro configuration file { "${apache2_conf}": ensure => present, content => template('apache/apache2.conf.erb'), owner => root, group => root, mode => 0644, notify => Service["apache"], } # apache alias configuration file { "${apache2_mods}-available/alias.conf": ensure => present, content => template('apache/alias.conf.erb'), owner => root, group => root, mode => 0644, notify => Service["apache"], } # apache autoindex configuration file { "${apache2_mods}-available/autoindex.conf": ensure => present, content => template('apache/autoindex.conf.erb'), owner => root, group => root, mode => 0644, notify => Service["apache"], } # icons folder # http://larsjung.de/h5ai/ # http://recursive-design.com/blog/2008/12/29/styling-apache-directory-listings-with-mod_autoindex/ # http://code.ecchi.ca/apache-tango-icons/README.html file { "${apache_www_folder}/icons": ensure => directory, recurse => true, purge => true, force => true, owner => "root", group => "root", # This mode will also apply to files from the source directory mode => 0644, # Puppet will automatically set +x for directories source => [ "puppet:///modules/site-apache/htdocs/$domain/icons", "puppet:///modules/apache/icons", ] } # default site configuration file { "${apache2_sites}-available/default": ensure => present, content => template('apache/default.erb'), owner => root, group => root, mode => 0644, notify => Service["apache"], } # https proxy configuration # see http://www.metaltoad.com/blog/running-drupal-secure-pages-behind-proxy file { "$apache2_conf_d/https-proxy": ensure => $apache_https_proxy ? { '' => absent, default => present, }, content => $apache_https_proxy ? { 'force' => "SetEnv HTTPS on\n", default => "SetEnvIf X-Forwarded-Proto https HTTPS=on\n", }, owner => root, group => root, mode => 0644, notify => Service["apache"], } # Notify this when apache needs a reload. This is only needed when # sites are added or removed, since a full restart then would be # a waste of time. When the module-config changes, a force-reload is # needed. exec { "reload-apache2": command => "/etc/init.d/apache2 reload", refreshonly => true, } exec { "force-reload-apache2": command => "/etc/init.d/apache2 force-reload", refreshonly => true, } }