Skip to content

Commit f515778

Browse files
committed
Merge pull request puppetlabs#1228 from wickedOne/rewritelock
RewriteLock support
2 parents 9c1047d + d38cc4d commit f515778

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,12 @@ If the [`vhost_dir`][] parameter's value differs from the [`confd_dir`][] parame
10651065

10661066
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`.
10671067

1068+
##### `rewrite_lock`
1069+
1070+
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'.
1071+
1072+
This parameter only applies to Apache version 2.2 or lower and is ignored on newer versions.
1073+
10681074
##### `sendfile`
10691075

10701076
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:
20232029
krb_method_negotiate => 'on',
20242030
krb_auth_realms => ['EXAMPLE.ORG'],
20252031
krb_local_user_mapping => 'on',
2026-
directories => {
2032+
directories => {
20272033
path => '/var/www/html',
20282034
auth_name => 'Kerberos Login',
20292035
auth_type => 'Kerberos',

manifests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
$conf_template = $::apache::params::conf_template,
5656
$servername = $::apache::params::servername,
5757
$pidfile = $::apache::params::pidfile,
58+
$rewrite_lock = undef,
5859
$manage_user = true,
5960
$manage_group = true,
6061
$user = $::apache::params::user,
@@ -296,6 +297,10 @@
296297
default => false
297298
}
298299

300+
if $rewrite_lock {
301+
validate_absolute_path($rewrite_lock)
302+
}
303+
299304
# Template uses:
300305
# - $pidfile
301306
# - $user
@@ -317,6 +322,7 @@
317322
# - $server_tokens
318323
# - $server_signature
319324
# - $trace_enable
325+
# - $rewrite_lock
320326
file { "${::apache::conf_dir}/${::apache::params::conf_file}":
321327
ensure => file,
322328
content => template($conf_template),

spec/classes/apache_spec.rb

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,23 @@
156156
:apache_version => '2.2',
157157
}
158158
end
159-
159+
160160
context "when default_type => 'none'" do
161161
let :params do
162162
{ :default_type => 'none' }
163163
end
164-
164+
165165
it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType none$} }
166166
end
167167
context "when default_type => 'text/plain'" do
168168
let :params do
169169
{ :default_type => 'text/plain' }
170170
end
171-
171+
172172
it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType text/plain$} }
173173
end
174174
end
175-
175+
176176
context "with Apache version >= 2.4" do
177177
let :params do
178178
{
@@ -388,6 +388,37 @@
388388
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} }
389389
end
390390

391+
context "with Apache version < 2.4" do
392+
let :params do
393+
{
394+
:apache_version => '2.2',
395+
:rewrite_lock => '/var/lock/subsys/rewrite-lock'
396+
}
397+
end
398+
399+
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^RewriteLock /var/lock/subsys/rewrite-lock$} }
400+
end
401+
402+
context "with Apache version < 2.4" do
403+
let :params do
404+
{
405+
:apache_version => '2.2'
406+
}
407+
end
408+
409+
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} }
410+
end
411+
412+
context "with Apache version >= 2.4" do
413+
let :params do
414+
{
415+
:apache_version => '2.4',
416+
:rewrite_lock => '/var/lock/subsys/rewrite-lock'
417+
}
418+
end
419+
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} }
420+
end
421+
391422
context "when specifying slash encoding behaviour" do
392423
let :params do
393424
{ :allow_encoded_slashes => 'nodecode' }

templates/httpd.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ KeepAlive <%= @keepalive %>
1111
MaxKeepAliveRequests <%= @max_keepalive_requests %>
1212
KeepAliveTimeout <%= @keepalive_timeout %>
1313

14+
<%- if @rewrite_lock and scope.function_versioncmp([@apache_version, '2.2']) <= 0 -%>
15+
RewriteLock <%= @rewrite_lock %>
16+
<%- end -%>
17+
1418
User <%= @user %>
1519
Group <%= @group %>
1620

0 commit comments

Comments
 (0)