From d38cc4d48f1ab1c027bfd44ac9574fbda2e00196 Mon Sep 17 00:00:00 2001 From: wickedOne Date: Fri, 16 Oct 2015 12:46:52 +0200 Subject: [PATCH] added rewrite lock tests and doc --- README.md | 8 +++++++- manifests/init.pp | 7 ++++++- spec/classes/apache_spec.rb | 39 +++++++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 51d2f5dad..8abaa5819 100644 --- a/README.md +++ b/README.md @@ -1065,6 +1065,12 @@ If the [`vhost_dir`][] parameter's value differs from the [`confd_dir`][] parame Setting `purge_vhost_dir` to 'false' is a stopgap measure to allow the apache Puppet module to coexist with existing or otherwise unmanaged configurations within `vhost_dir`. +##### `rewrite_lock` + +Allows setting a custom location for a rewrite lock - considered best practice if using a RewriteMap of type prg in the [`rewrites`][] parameter of your vhost. Default: 'undef'. + +This parameter only applies to Apache version 2.2 or lower and is ignored on newer versions. + ##### `sendfile` Forces Apache to use the Linux kernel's `sendfile` support to serve static files, via the [`EnableSendfile`][] directive. Valid options: 'On', 'Off'. Default: 'On'. @@ -2023,7 +2029,7 @@ Usage typically looks like: krb_method_negotiate => 'on', krb_auth_realms => ['EXAMPLE.ORG'], krb_local_user_mapping => 'on', - directories => { + directories => { path => '/var/www/html', auth_name => 'Kerberos Login', auth_type => 'Kerberos', diff --git a/manifests/init.pp b/manifests/init.pp index de6472f9e..d894e324f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,7 +55,7 @@ $conf_template = $::apache::params::conf_template, $servername = $::apache::params::servername, $pidfile = $::apache::params::pidfile, - $rewrite_lock = false, + $rewrite_lock = undef, $manage_user = true, $manage_group = true, $user = $::apache::params::user, @@ -297,6 +297,10 @@ default => false } + if $rewrite_lock { + validate_absolute_path($rewrite_lock) + } + # Template uses: # - $pidfile # - $user @@ -318,6 +322,7 @@ # - $server_tokens # - $server_signature # - $trace_enable + # - $rewrite_lock file { "${::apache::conf_dir}/${::apache::params::conf_file}": ensure => file, content => template($conf_template), diff --git a/spec/classes/apache_spec.rb b/spec/classes/apache_spec.rb index b82eafa0d..0f4d0c5ba 100644 --- a/spec/classes/apache_spec.rb +++ b/spec/classes/apache_spec.rb @@ -156,23 +156,23 @@ :apache_version => '2.2', } end - + context "when default_type => 'none'" do let :params do { :default_type => 'none' } end - + it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType none$} } end context "when default_type => 'text/plain'" do let :params do { :default_type => 'text/plain' } end - + it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType text/plain$} } end end - + context "with Apache version >= 2.4" do let :params do { @@ -388,6 +388,37 @@ it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} } end + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + :rewrite_lock => '/var/lock/subsys/rewrite-lock' + } + end + + it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^RewriteLock /var/lock/subsys/rewrite-lock$} } + end + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2' + } + end + + it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + :rewrite_lock => '/var/lock/subsys/rewrite-lock' + } + end + it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} } + end + context "when specifying slash encoding behaviour" do let :params do { :allow_encoded_slashes => 'nodecode' }