From 9cbf2fafee3f4623b75d1a6b70458ab097e64924 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jun 2012 12:09:39 -0300 Subject: fix dynamic scope variables, function access --- manifests/vhost.pp | 6 +++++- manifests/vhost/modperl.pp | 2 +- manifests/vhost/passenger.pp | 2 +- manifests/vhost/php/standard.pp | 2 +- manifests/vhost/php/webapp.pp | 13 +++++++++++++ manifests/vhost/template.pp | 4 +++- templates/vhosts/default.erb | 10 +++++----- templates/vhosts/gitweb/partial.erb | 2 +- templates/vhosts/itk_plus.erb | 6 +++--- templates/vhosts/itk_plus/partial.erb | 2 +- templates/vhosts/partials/header_default.erb | 12 ++++++------ templates/vhosts/passenger/partial.erb | 2 +- templates/vhosts/perl/partial.erb | 6 +++--- templates/vhosts/php/partial.erb | 8 ++++---- templates/vhosts/php_drupal/partial.erb | 6 +++--- templates/vhosts/php_gallery2/partial.erb | 8 ++++---- templates/vhosts/php_joomla/partial.erb | 8 ++++---- templates/vhosts/php_mediawiki/partial.erb | 4 ++-- templates/vhosts/php_silverstripe/partial.erb | 8 ++++---- templates/vhosts/php_typo3/partial.erb | 4 ++-- templates/vhosts/proxy/partial.erb | 4 ++-- templates/vhosts/redirect/partial.erb | 2 +- templates/vhosts/static/partial.erb | 6 +++--- templates/vhosts/webdav/partial.erb | 2 +- 24 files changed, 74 insertions(+), 55 deletions(-) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 64c20c7..90af00d 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -62,7 +62,9 @@ define apache::vhost( $mod_security_additional_options = 'absent', $use_mod_macro = false, $ldap_auth = false, - $ldap_user = 'any' + $ldap_user = 'any', + $passing_extension = 'absent', + $gempath = 'absent' ) { # file or template mode? case $vhost_mode { @@ -111,6 +113,8 @@ define apache::vhost( mod_security_rules_to_disable => $mod_security_rules_to_disable, mod_security_additional_options => $mod_security_additional_options, use_mod_macro => $use_mod_macro, + passing_extension => $passing_extension, + gempath => $gempath, } } default: { fail("no such vhost_mode: $vhost_mode defined for $name.") } diff --git a/manifests/vhost/modperl.pp b/manifests/vhost/modperl.pp index 35842dc..c93e6cf 100644 --- a/manifests/vhost/modperl.pp +++ b/manifests/vhost/modperl.pp @@ -83,7 +83,6 @@ define apache::vhost::modperl( mode => $documentroot_mode; } - $passing_extension = 'pl' if $ensure != 'absent' { case $run_mode { 'proxy-itk','static-itk': { @@ -146,6 +145,7 @@ define apache::vhost::modperl( mod_security_relevantonly => $mod_security_relevantonly, mod_security_rules_to_disable => $mod_security_rules_to_disable, mod_security_additional_options => $mod_security_additional_options, + passing_extension => 'pl' } } diff --git a/manifests/vhost/passenger.pp b/manifests/vhost/passenger.pp index 0507add..6886f13 100644 --- a/manifests/vhost/passenger.pp +++ b/manifests/vhost/passenger.pp @@ -76,7 +76,6 @@ define apache::vhost::passenger( }, default => $path } - $gempath = "${real_path}/gems" file{ ["${real_path}/www/tmp", "${real_path}/www/log"]: ensure => directory, @@ -132,6 +131,7 @@ define apache::vhost::passenger( mod_security_relevantonly => $mod_security_relevantonly, mod_security_rules_to_disable => $mod_security_rules_to_disable, mod_security_additional_options => $mod_security_additional_options, + gempath => "${real_path}/gems" } } diff --git a/manifests/vhost/php/standard.pp b/manifests/vhost/php/standard.pp index b02e05c..bbfebc4 100644 --- a/manifests/vhost/php/standard.pp +++ b/manifests/vhost/php/standard.pp @@ -178,7 +178,6 @@ define apache::vhost::php::standard( $real_php_settings = merge($std_php_settings,$php_settings) - $passing_extension = 'php' if $ensure != 'absent' { case $run_mode { 'proxy-itk','static-itk': { @@ -245,6 +244,7 @@ define apache::vhost::php::standard( mod_security_rules_to_disable => $mod_security_rules_to_disable, mod_security_additional_options => $mod_security_additional_options, use_mod_macro => $use_mod_macro, + passing_extension => $passing_extension, } } diff --git a/manifests/vhost/php/webapp.pp b/manifests/vhost/php/webapp.pp index 3711c1a..54905ca 100644 --- a/manifests/vhost/php/webapp.pp +++ b/manifests/vhost/php/webapp.pp @@ -75,6 +75,19 @@ define apache::vhost::php::webapp( if $manage_config { if $config_file == 'absent' { fail("No config file defined for ${name} on ${::fqdn}, if you'd like to manage the config, you have to add one!") } + + $real_path = $path ? { + 'absent' => $::operatingsystem ? { + openbsd => "/var/www/htdocs/${name}", + default => "/var/www/vhosts/${name}" + }, + default => $path + } + if $path_is_webdir { + $documentroot = $real_path + } else { + $documentroot = "${real_path}/www" + } ::apache::vhost::file::documentrootfile{"configurationfile_${name}": documentroot => $documentroot, filename => $config_file, diff --git a/manifests/vhost/template.pp b/manifests/vhost/template.pp index c19faba..4c9ab3f 100644 --- a/manifests/vhost/template.pp +++ b/manifests/vhost/template.pp @@ -71,7 +71,9 @@ define apache::vhost::template( $htpasswd_file = 'absent', $htpasswd_path = 'absent', $ldap_auth = false, - $ldap_user = 'any' + $ldap_user = 'any', + $passing_extension = 'absent', + $gempath = 'absent' ){ $real_path = $path ? { 'absent' => $::operatingsystem ? { diff --git a/templates/vhosts/default.erb b/templates/vhosts/default.erb index 9342d06..62edf69 100644 --- a/templates/vhosts/default.erb +++ b/templates/vhosts/default.erb @@ -10,9 +10,9 @@ vhost_parts.each do |vhost_part| -%> > -<%= scope.function_template('apache/vhosts/partials/header_default.erb') %> +<%= scope.function_template(['apache/vhosts/partials/header_default.erb']) %> -<%= scope.function_template('apache/vhosts/partials/logs.erb') %> +<%= scope.function_template(['apache/vhosts/partials/logs.erb']) %> <% if run_mode.to_s =~ /(proxy\-|static\-)?itk/ -%> @@ -33,13 +33,13 @@ vhost_parts.each do |vhost_part| RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{SERVER_NAME}$1 [R=permanent,L] <% else -%> -<%= scope.function_template(template_partial) %> +<%= scope.function_template([template_partial]) %> <% end -%> <%- unless template_partial == 'apache/vhosts/itk_plus/partial.erb' -%> -<%= scope.function_template('apache/vhosts/partials/mod_security.erb') %> +<%= scope.function_template(['apache/vhosts/partials/mod_security.erb']) %> <% end -%> <% unless additional_options.to_s == 'absent' -%> <%= additional_options %> <% end -%> -<% end -%> \ No newline at end of file +<% end -%> diff --git a/templates/vhosts/gitweb/partial.erb b/templates/vhosts/gitweb/partial.erb index 8bfe6ce..7238ebe 100644 --- a/templates/vhosts/gitweb/partial.erb +++ b/templates/vhosts/gitweb/partial.erb @@ -14,6 +14,6 @@ RewriteEngine on RewriteRule ^[a-zA-Z0-9_-]+.git/?(\?.)?$ /gitweb.cgi%{REQUESTURI} [L,PT] -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> <% end -%> diff --git a/templates/vhosts/itk_plus.erb b/templates/vhosts/itk_plus.erb index 2890ecf..b7cb180 100644 --- a/templates/vhosts/itk_plus.erb +++ b/templates/vhosts/itk_plus.erb @@ -1,10 +1,10 @@ -<%= scope.function_template('apache/vhost/default.erb') %> +<%= scope.function_template(['apache/vhost/default.erb']) %> <% scope.unsetvar('template_partial') scope.setvar('template_partial','apache/vhosts/itk_plus/partial.erb') -%> -<%= scope.function_template('apache/vhost/default.erb') %> - \ No newline at end of file +<%= scope.function_template(['apache/vhost/default.erb']) %> + diff --git a/templates/vhosts/itk_plus/partial.erb b/templates/vhosts/itk_plus/partial.erb index e37e418..5b05dd8 100644 --- a/templates/vhosts/itk_plus/partial.erb +++ b/templates/vhosts/itk_plus/partial.erb @@ -25,7 +25,7 @@ Options <% unless options.to_s == 'absent' then -%><%= options %><% end -%><% if do_includes.to_s == 'true' and not options.include?('+Includes') then -%> +Includes<% end -%> <% end -%> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> <% end -%> diff --git a/templates/vhosts/partials/header_default.erb b/templates/vhosts/partials/header_default.erb index a9a87bc..d6d8c86 100644 --- a/templates/vhosts/partials/header_default.erb +++ b/templates/vhosts/partials/header_default.erb @@ -3,18 +3,18 @@ Include include.d/ssl_defaults.inc <% end -%> ServerName <%= servername %> -<% unless serveralias.to_s.empty? || (serveralias.to_s == 'absent') -%> +<% unless serveralias.empty? || (serveralias == 'absent') -%> ServerAlias <%= serveralias %> <% end -%> -<% unless server_admin.to_s.empty? || (server_admin.to_s == 'absent') -%> +<% unless server_admin.empty? || (server_admin == 'absent') -%> ServerAdmin <%= server_admin %> <% end -%> -<% unless documentroot.to_s == 'really_absent' -%> +<% unless documentroot == 'really_absent' -%> DocumentRoot <%= documentroot %>/ <% end -%> -<% if default_charset.to_s != 'absent' then -%> +<% if default_charset != 'absent' then -%> AddDefaultCharset <%= default_charset %> <% end -%> -<% if has_variable?('passing_extension') && !passing_extension.to_s.empty? -%> +<% if passing_extension != 'absent' -%> DirectoryIndex index.htm index.html index.<%= passing_extension %> -<% end -%> \ No newline at end of file +<% end -%> diff --git a/templates/vhosts/passenger/partial.erb b/templates/vhosts/passenger/partial.erb index abbec79..490649e 100644 --- a/templates/vhosts/passenger/partial.erb +++ b/templates/vhosts/passenger/partial.erb @@ -3,5 +3,5 @@ AllowOverride <%= allow_override %> Options <%- unless options.to_s == 'absent' -%><%= options %><%- end -%><%- unless !options.to_s.include?('MultiViews') -%>-MultiViews<%- end -%> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> diff --git a/templates/vhosts/perl/partial.erb b/templates/vhosts/perl/partial.erb index f75bf3f..a8c30c3 100644 --- a/templates/vhosts/perl/partial.erb +++ b/templates/vhosts/perl/partial.erb @@ -1,7 +1,7 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> <% unless htpasswd_file.to_s == 'absent' -%> @@ -12,4 +12,4 @@ require valid-user <% end -%> - ScriptAlias /cgi-bin/ <%= cgi_binpath %>/ \ No newline at end of file + ScriptAlias /cgi-bin/ <%= cgi_binpath %>/ diff --git a/templates/vhosts/php/partial.erb b/templates/vhosts/php/partial.erb index dae201a..f8e5c53 100644 --- a/templates/vhosts/php/partial.erb +++ b/templates/vhosts/php/partial.erb @@ -1,7 +1,7 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/php_settings.erb') %> +<%= scope.function_template(['apache/vhosts/partials/php_settings.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> - \ No newline at end of file +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> + diff --git a/templates/vhosts/php_drupal/partial.erb b/templates/vhosts/php_drupal/partial.erb index 07e0d94..3c420b1 100644 --- a/templates/vhosts/php_drupal/partial.erb +++ b/templates/vhosts/php_drupal/partial.erb @@ -1,10 +1,10 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> -<%= scope.function_template('apache/vhosts/partials/php_settings.erb') %> +<%= scope.function_template(['apache/vhosts/partials/php_settings.erb']) %> # Protect files and directories from prying eyes. diff --git a/templates/vhosts/php_gallery2/partial.erb b/templates/vhosts/php_gallery2/partial.erb index 05cc9f4..448f720 100644 --- a/templates/vhosts/php_gallery2/partial.erb +++ b/templates/vhosts/php_gallery2/partial.erb @@ -1,9 +1,9 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/php_settings.erb') %> +<%= scope.function_template(['apache/vhosts/partials/php_settings.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> <% if vhost_part != :ssl -%> # Always rewrite login's @@ -13,4 +13,4 @@ RewriteCond %{QUERY_STRING} subView=core\.UserLogin RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R,L] <% end -%> - \ No newline at end of file + diff --git a/templates/vhosts/php_joomla/partial.erb b/templates/vhosts/php_joomla/partial.erb index fa095ff..526352a 100644 --- a/templates/vhosts/php_joomla/partial.erb +++ b/templates/vhosts/php_joomla/partial.erb @@ -1,9 +1,9 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/php_settings.erb') %> +<%= scope.function_template(['apache/vhosts/partials/php_settings.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> Include include.d/joomla.inc @@ -16,4 +16,4 @@ RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} (.*/administrator/.*) RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R] - \ No newline at end of file + diff --git a/templates/vhosts/php_mediawiki/partial.erb b/templates/vhosts/php_mediawiki/partial.erb index 38f9663..cf30f5f 100644 --- a/templates/vhosts/php_mediawiki/partial.erb +++ b/templates/vhosts/php_mediawiki/partial.erb @@ -4,7 +4,7 @@ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d RewriteRule ^/?index.php/(.*)$ /index.php?title=$1 [PT,L,QSA] <% end -%> -<%= scope.function_template('apache/vhosts/php/partial.erb') %> +<%= scope.function_template(['apache/vhosts/php/partial.erb']) %> /typo3/"> RewriteEngine on @@ -13,4 +13,4 @@ RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} (.*/typo3/.*) RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R] - \ No newline at end of file + diff --git a/templates/vhosts/php_silverstripe/partial.erb b/templates/vhosts/php_silverstripe/partial.erb index a398829..89a6052 100644 --- a/templates/vhosts/php_silverstripe/partial.erb +++ b/templates/vhosts/php_silverstripe/partial.erb @@ -6,11 +6,11 @@ <% end -%> /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/php_settings.erb') %> +<%= scope.function_template(['apache/vhosts/partials/php_settings.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> Include include.d/silverstripe.inc - \ No newline at end of file + diff --git a/templates/vhosts/php_typo3/partial.erb b/templates/vhosts/php_typo3/partial.erb index 776fff2..5c06570 100644 --- a/templates/vhosts/php_typo3/partial.erb +++ b/templates/vhosts/php_typo3/partial.erb @@ -1,4 +1,4 @@ -<%= scope.function_template('apache/vhosts/php/partial.erb') %> +<%= scope.function_template(['apache/vhosts/php/partial.erb']) %> /typo3/"> RewriteEngine on @@ -7,4 +7,4 @@ RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} (.*/typo3/.*) RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R] - \ No newline at end of file + diff --git a/templates/vhosts/proxy/partial.erb b/templates/vhosts/proxy/partial.erb index f0d4c9d..bbf3c64 100644 --- a/templates/vhosts/proxy/partial.erb +++ b/templates/vhosts/proxy/partial.erb @@ -1,8 +1,8 @@ Order deny,allow Allow from all -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> ProxyRequests Off ProxyPass / <%= options %>/ - ProxyPassReverse / <%= options %>/ \ No newline at end of file + ProxyPassReverse / <%= options %>/ diff --git a/templates/vhosts/redirect/partial.erb b/templates/vhosts/redirect/partial.erb index bd012c8..3b7af7a 100644 --- a/templates/vhosts/redirect/partial.erb +++ b/templates/vhosts/redirect/partial.erb @@ -1 +1 @@ - Redirect permanent / https://<%= options %> \ No newline at end of file + Redirect permanent / https://<%= options %> diff --git a/templates/vhosts/static/partial.erb b/templates/vhosts/static/partial.erb index 78dc925..f2cc46b 100644 --- a/templates/vhosts/static/partial.erb +++ b/templates/vhosts/static/partial.erb @@ -1,5 +1,5 @@ /"> -<%= scope.function_template('apache/vhosts/partials/std_override_options.erb') %> +<%= scope.function_template(['apache/vhosts/partials/std_override_options.erb']) %> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> - \ No newline at end of file +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> + diff --git a/templates/vhosts/webdav/partial.erb b/templates/vhosts/webdav/partial.erb index 2f78d7b..d89da50 100644 --- a/templates/vhosts/webdav/partial.erb +++ b/templates/vhosts/webdav/partial.erb @@ -9,7 +9,7 @@ Options Indexes <%- end -%> -<%= scope.function_template('apache/vhosts/partials/authentication.erb') %> +<%= scope.function_template(['apache/vhosts/partials/authentication.erb']) %> <%- if ldap_auth.to_s == 'true' then -%> Include include.d/ldap_auth.inc <%- unless ldap_user.to_s == 'any' -%> -- cgit v1.2.3