]> gitweb.fluxo.info Git - puppet-apache.git/commitdiff
Upgrading for 2.7 compatibility
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 19 Jan 2013 18:04:58 +0000 (16:04 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 19 Jan 2013 18:04:58 +0000 (16:04 -0200)
manifests/init.pp
manifests/module.pp
manifests/passenger.pp
manifests/site.pp
templates/alias.conf.erb
templates/apache2.conf.erb
templates/default.erb
templates/error.erb
templates/macros.erb

index d6428c058402aceb1018cf9cb30fdba9281c44dc..42db66400495e1b15e366d58b3966a123b106f86 100644 (file)
 #  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(
+  $sites          = "/etc/apache2/sites"
+  $mods           = "/etc/apache2/mods"
+  $conf_d         = "/etc/apache2/conf.d"
+  $macros         = "/etc/apache2/conf.d/macros"
+  $conf           = "/etc/apache2/apache2.conf"
+  $www_folder     = "/var/www/data"
+  $error_folder   = "/var/www/error"
+  $sites_folder   = "/var/sites"
+  $error_dest     = "http://${domain}/missing.html"
+  $default_folder = '/var/www/data'
+  $server_name    = $hostname
+  $https_proxy    = 'no'
+) {
 
-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,
@@ -97,7 +80,7 @@ class apache {
   }
 
   # apache mod_macro configuration
-  file { "${apache2_macros}":
+  file { "${macros}":
     ensure  => present,
     content => template('apache/macros.erb'),
     owner   => root,
@@ -108,7 +91,7 @@ class apache {
   }
 
   # apache mod_macro configuration
-  file { "${apache2_conf}":
+  file { "${conf}":
     ensure  => present,
     content => template('apache/apache2.conf.erb'),
     owner   => root,
@@ -118,7 +101,7 @@ class apache {
   }
 
   # apache alias configuration
-  file { "${apache2_mods}-available/alias.conf":
+  file { "${mods}-available/alias.conf":
     ensure  => present,
     content => template('apache/alias.conf.erb'),
     owner   => root,
@@ -128,7 +111,7 @@ class apache {
   }
 
   # apache autoindex configuration
-  file { "${apache2_mods}-available/autoindex.conf":
+  file { "${mods}-available/autoindex.conf":
     ensure  => present,
     content => template('apache/autoindex.conf.erb'),
     owner   => root,
@@ -141,7 +124,7 @@ class apache {
   # 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":
+  file { "${www_folder}/icons":
     ensure  => directory,
     recurse => true,
     purge   => true,
@@ -151,12 +134,12 @@ class apache {
     # 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",
+    source  => [ "puppet:///modules/site_apache/htdocs/$domain/icons",
                  "puppet:///modules/apache/icons", ]
   }
 
   # default site configuration
-  file { "${apache2_sites}-available/default":
+  file { "${sites}-available/default":
     ensure  => present,
     content => template('apache/default.erb'),
     owner   => root,
@@ -167,12 +150,12 @@ class 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 ? {
+  file { "$conf_d/https-proxy":
+    ensure => $https_proxy ? {
       ''      => absent,
       default => present,
     },
-    content => $apache_https_proxy ? {
+    content => $https_proxy ? {
       'force' => "SetEnv HTTPS on\n",
       default => "SetEnvIf X-Forwarded-Proto https HTTPS=on\n",
     },
index 8a364323315328be2bf22cc8e24d5c80c6f07ed7..64a692c8557bc6c9b1a612d49132478cb75bc2a0 100644 (file)
@@ -8,15 +8,15 @@ define apache::module($ensure = 'present') {
   case $ensure {
     'present': {
       exec { "/usr/sbin/a2enmod $name":
-        unless  => "/bin/sh -c '[ -L ${apache2_mods}-enabled/${name}.load ] \
-                && [ ${apache2_mods}-enabled/${name}.load -ef ${apache2_mods}-available/${name}.load ]'",
+        unless  => "/bin/sh -c '[ -L ${apache::mods}-enabled/${name}.load ] \
+                && [ ${apache::mods}-enabled/${name}.load -ef ${apache::mods}-available/${name}.load ]'",
         notify  => Exec["force-reload-apache2"],
       }
     }
     'absent': {
       exec { "/usr/sbin/a2dismod $name":
-        onlyif  => "/bin/sh -c '[ -L ${apache2_mods}-enabled/${name}.load ] \
-                && [ ${apache2_mods}-enabled/${name}.load -ef ${apache2_mods}-available/${name}.load ]'",
+        onlyif  => "/bin/sh -c '[ -L ${apache::mods}-enabled/${name}.load ] \
+                && [ ${apache::mods}-enabled/${name}.load -ef ${apache::mods}-available/${name}.load ]'",
         notify  => Exec["force-reload-apache2"],
       }
     }
index 92230f09dcc480e91d856f5395d531723d5f02d0..1ebcb142fc11dd72a089648c324c1ca39f14b0ce 100644 (file)
@@ -1,4 +1,4 @@
-class apache::passenger inherits apache {
+class apache::passenger {
   package { "mod_rack":
     name   => "libapache2-mod-passenger",
     ensure => installed,                                                                                                     
index 0c68361b0dba6198e5e0bb12673fe0b5a0a7edff..d5046daf9f4812f6b2ff4f6ea2cc55bc303a7d08 100644 (file)
@@ -109,25 +109,25 @@ define apache::site($ensure = present, $docroot = false, $redirect = false,
 
   case $source {
     true: {
-             file { "${apache2_sites}-available/$vhost":
+             file { "${apache::sites}-available/$vhost":
                ensure  => $ensure,
                source  => [ "puppet:///modules/site-apache/vhosts/$domain/$title", 
                             "puppet:///modules/site-apache/vhosts/$title" ],
                owner   => root,
                group   => root,
                mode    => 0644,
-               require => File["${apache2_macros}"],
+               require => File["${apache::macros}"],
                notify  => Service["apache"],
              }
            }
     false: {
-             file { "${apache2_sites}-available/$vhost":
+             file { "${apache::sites}-available/$vhost":
                ensure  => $ensure,
                content => template("$template"),
                owner   => root,
                group   => root,
                mode    => 0644,
-               require => File["${apache2_macros}"],
+               require => File["${apache::macros}"],
                notify  => Service["apache"],
              }
            }
@@ -136,7 +136,7 @@ define apache::site($ensure = present, $docroot = false, $redirect = false,
   # Enable the site without a2ensite
   #
   #$status = $ensure ? {
-  #  'present' => "${apache2_sites}-available/$vhost",
+  #  'present' => "${apache::sites}-available/$vhost",
   #  default   => 'absent',
   #}
   #
@@ -144,7 +144,7 @@ define apache::site($ensure = present, $docroot = false, $redirect = false,
   #  ensure  => $status,
   #  owner   => root,
   #  group   => root,
-  #  require => File["${apache2_sites}-available/$title"],
+  #  require => File["${apache::sites}-available/$title"],
   #  notify  => Service["apache"],
   #}
 
@@ -171,19 +171,19 @@ define apache::site($ensure = present, $docroot = false, $redirect = false,
         }
       }
       exec { "/usr/sbin/a2ensite $vhost":
-        unless  => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$vhost ] \
-                && [ ${apache2_sites}-enabled/$vhost -ef ${apache2_sites}-available/$vhost ]'",
+        unless  => "/bin/sh -c '[ -L ${apache::sites}-enabled/$vhost ] \
+                && [ ${apache::sites}-enabled/$vhost -ef ${apache::sites}-available/$vhost ]'",
         notify  => Exec["reload-apache2"],
       }
     }
     'absent': {
       exec { "/usr/sbin/a2dissite $vhost":
-        onlyif  => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$vhost ] \
-                && [ ${apache2_sites}-enabled/$vhost -ef ${apache2_sites}-available/$vhost ]'",
+        onlyif  => "/bin/sh -c '[ -L ${apache::sites}-enabled/$vhost ] \
+                && [ ${apache::sites}-enabled/$vhost -ef ${apache::sites}-available/$vhost ]'",
         notify  => Exec["reload-apache2"],
       }
 
-      file { "${apache2_sites}-enabled/$vhost":
+      file { "${apache::sites}-enabled/$vhost":
         ensure => absent,
         notify => Exec["reload-apache2"],
       }
index 4e96ad1406c8e93cd55a59ce0d0df717740668c1..cd74c663a32b7c68fe218a2340a100f75b12effb 100644 (file)
@@ -12,9 +12,9 @@
 # We include the /icons/ alias for FancyIndexed directory listings.  If
 # you do not use FancyIndexing, you may comment this out.
 #
-Alias /icons "<%= apache_www_folder %>/icons"
+Alias /icons "<%= scope.lookupvar('apache::www_folder') %>/icons"
 
-<Directory "<%= apache_www_folder %>/icons">
+<Directory "<%= scope.lookupvar('apache::www_folder') %>/icons">
     Options Indexes MultiViews
     AllowOverride None
     Order allow,deny
index 26760b63126e8786967d2b91089103756c2d8972..60cc2b38ad60b0236596ebec3123e8722ff661ec 100644 (file)
@@ -35,7 +35,7 @@
 # such as the number of concurrent requests it can handle or where it
 # can find its configuration files.
 #
-ServerName <%= apache_server_name %>.<%= domain %>
+ServerName <%= scope.lookupvar('apache::server_name') %>.<%= domain %>
 
 #
 # ServerRoot: The top of the directory tree under which the server's
index b7175b05ce314bc7ea05a835eba5a7fda0ef4d10..a4361b7269ed3111853157edf58a14f7b67f6e88 100644 (file)
@@ -1,10 +1,10 @@
 # begin vhost for <%= fqdn %>
 <VirtualHost *:80>
    ServerName <%= fqdn %>
-   DocumentRoot <%= apache_default_folder %>
+   DocumentRoot <%= scope.lookupvar('apache::default_folder') %>
       
    # begin site config
-   <Directory <%= apache_default_folder %>>
+   <Directory <%= scope.lookupvar('apache::default_folder') %>>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
index e0dbb0e950d9b959b29a1cc010c4b11fdfba6b5b..70693feb9f6f54effcab4ec36a263ec12b4b7dcb 100644 (file)
@@ -2,10 +2,10 @@
 <VirtualHost *:80>
   ServerName error.<%= hosting_domain %>
   ServerAlias *.<%= hosting_domain %>
-  DocumentRoot <%= apache_error_folder %>
-  ErrorDocument 404 <%= apache_error_dest %>
+  DocumentRoot <%= scope.lookupvar('apache::error_folder') %>
+  ErrorDocument 404 <%= scope.lookupvar('apache::error_dest') %>
 
-  <Directory <%= apache_error_folder %>>
+  <Directory <%= scope.lookupvar('apache::error_folder') %>>
     DirectoryIndex index.html
     Options Indexes -Includes FollowSymLinks -MultiViews
     AllowOverride None
index 2f7941f0249fca41512b78cf73d9129fb0c7c592..1cabce5ba2f856a778071708f17b13c527316124 100644 (file)
@@ -21,7 +21,7 @@
 
 <Macro Drupal $version>
    # begin drupal config
-   <Directory <%= apache_www_folder %>/drupal-$version>
+   <Directory <%= scope.lookupvar('apache::www_folder') %>/drupal-$version>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -30,7 +30,7 @@
 
 <Macro Wiki $site>
    # begin wiki config
-   <Directory <%= apache_sites_folder %>/$site/wiki>
+   <Directory <%= scope.lookupvar('apache::sites_folder') %>/$site/wiki>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -39,7 +39,7 @@
 
 <Macro Site $name>
    # begin site config
-   <Directory <%= apache_sites_folder %>/$name/site>
+   <Directory <%= scope.lookupvar('apache::sites_folder') %>/$name/site>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -52,7 +52,7 @@
      SetHandler mod_python
      PythonInterpreter main_interpreter
      PythonHandler trac.web.modpython_frontend
-     PythonOption TracEnv <%= apache_sites_folder %>/$site/trac
+     PythonOption TracEnv <%= scope.lookupvar('apache::sites_folder') %>/$site/trac
      PythonOption TracUriRoot /trac
 
      # This prevents strange behavior when using trac
@@ -64,7 +64,7 @@
    <Location "/trac/login">
      AuthType Basic
      AuthName "Trac $site"
-     AuthUserFile <%= apache_sites_folder %>/$site/trac/auth/.htpasswd
+     AuthUserFile <%= scope.lookupvar('apache::sites_folder') %>/$site/trac/auth/.htpasswd
      Require valid-user
    </Location>
    # end trac config
    Alias /moinroot /usr/share/moin/htdocs/
    AliasMatch ^/moin_static[0-9]*/(.*)$ /usr/share/moin/htdocs/$1
    # TODO: fastcgi
-   ScriptAlias /moin "<%= apache_sites_folder %>/$site/moin/cgi-bin/moin.cgi"
+   ScriptAlias /moin "<%= scope.lookupvar('apache::sites_folder') %>/$site/moin/cgi-bin/moin.cgi"
    # end moin config
 </Macro>
 
 <Macro Ikiwiki $name>
    # begin ikiwiki config
-   <Directory <%= apache_sites_folder %>/$name/ikiwiki>
+   <Directory <%= scope.lookupvar('apache::sites_folder') %>/$name/ikiwiki>
       Options Indexes Includes FollowSymLinks MultiViews ExecCGI
       AllowOverride All
    </Directory>
@@ -92,7 +92,7 @@
    # begin rails config
    PassengerUploadBufferDir /tmp
 
-   <Directory <%= apache_sites_folder %>/$name/site>
+   <Directory <%= scope.lookupvar('apache::sites_folder') %>/$name/site>
       Options -MultiViews
       AllowOverride All
       RailsBaseURI /