diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-01-19 16:04:58 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-01-19 16:04:58 -0200 |
commit | 2c16c4788cc352a79c548fd9164d65264ae55d22 (patch) | |
tree | 536f777142d2117405a005f44936b6b0d55ab002 | |
parent | 35690aec253a16ca0c48f4fb249ce940dc5f48e0 (diff) | |
download | puppet-apache-2c16c4788cc352a79c548fd9164d65264ae55d22.tar.gz puppet-apache-2c16c4788cc352a79c548fd9164d65264ae55d22.tar.bz2 |
Upgrading for 2.7 compatibility
-rw-r--r-- | manifests/init.pp | 65 | ||||
-rw-r--r-- | manifests/module.pp | 8 | ||||
-rw-r--r-- | manifests/passenger.pp | 2 | ||||
-rw-r--r-- | manifests/site.pp | 22 | ||||
-rw-r--r-- | templates/alias.conf.erb | 4 | ||||
-rw-r--r-- | templates/apache2.conf.erb | 2 | ||||
-rw-r--r-- | templates/default.erb | 4 | ||||
-rw-r--r-- | templates/error.erb | 6 | ||||
-rw-r--r-- | templates/macros.erb | 16 |
9 files changed, 56 insertions, 73 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index d6428c0..42db664 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,40 +24,23 @@ # 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", }, diff --git a/manifests/module.pp b/manifests/module.pp index 8a36432..64a692c 100644 --- a/manifests/module.pp +++ b/manifests/module.pp @@ -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"], } } diff --git a/manifests/passenger.pp b/manifests/passenger.pp index 92230f0..1ebcb14 100644 --- a/manifests/passenger.pp +++ b/manifests/passenger.pp @@ -1,4 +1,4 @@ -class apache::passenger inherits apache { +class apache::passenger { package { "mod_rack": name => "libapache2-mod-passenger", ensure => installed, diff --git a/manifests/site.pp b/manifests/site.pp index 0c68361..d5046da 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -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"], } diff --git a/templates/alias.conf.erb b/templates/alias.conf.erb index 4e96ad1..cd74c66 100644 --- a/templates/alias.conf.erb +++ b/templates/alias.conf.erb @@ -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 diff --git a/templates/apache2.conf.erb b/templates/apache2.conf.erb index 26760b6..60cc2b3 100644 --- a/templates/apache2.conf.erb +++ b/templates/apache2.conf.erb @@ -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 diff --git a/templates/default.erb b/templates/default.erb index b7175b0..a4361b7 100644 --- a/templates/default.erb +++ b/templates/default.erb @@ -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> diff --git a/templates/error.erb b/templates/error.erb index e0dbb0e..70693fe 100644 --- a/templates/error.erb +++ b/templates/error.erb @@ -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 diff --git a/templates/macros.erb b/templates/macros.erb index 2f7941f..1cabce5 100644 --- a/templates/macros.erb +++ b/templates/macros.erb @@ -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 @@ -75,13 +75,13 @@ 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 / |