Skip to content

Commit 9cc8f3d

Browse files
author
Morgan Haskel
committed
MODULES-956 Added loadfile_name parameter to apache::mod.
This will allow for more control over the module load order, since they appear to be loaded alphabetically.
1 parent 81069bc commit 9cc8f3d

3 files changed

Lines changed: 45 additions & 9 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ Sets the amount of time the server will wait for subsequent requests on a persis
310310

311311
Sets the limit of the number of requests allowed per connection when KeepAlive is on. Defaults to '100'.
312312

313+
#####`loadfile_name`
314+
315+
Sets the file name for the module loadfile. Should be in the format *.load. This can be used to set the module load order.
316+
313317
#####`log_level`
314318

315319
Changes the verbosity level of the error log. Defaults to 'warn'. Valid values are 'emerg', 'alert', 'crit', 'error', 'warn', 'notice', 'info', or 'debug'.

manifests/mod.pp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
define apache::mod (
2-
$package = undef,
2+
$package = undef,
33
$package_ensure = 'present',
4-
$lib = undef,
5-
$lib_path = $::apache::params::lib_path,
6-
$id = undef,
7-
$path = undef,
8-
$loadfiles = undef,
4+
$lib = undef,
5+
$lib_path = $::apache::params::lib_path,
6+
$id = undef,
7+
$path = undef,
8+
$loadfile_name = undef,
9+
$loadfiles = undef,
910
) {
1011
if ! defined(Class['apache']) {
1112
fail('You must include the apache base class before using any apache defined resources')
@@ -39,6 +40,12 @@
3940
$_id = "${mod}_module"
4041
}
4142

43+
if $loadfile_name {
44+
$_loadfile_name = $loadfile_name
45+
} else {
46+
$_loadfile_name = "${mod}.load"
47+
}
48+
4249
# Determine if we have a package
4350
$mod_packages = $::apache::params::mod_packages
4451
$mod_package = $mod_packages[$mod] # 2.6 compatibility hack
@@ -69,7 +76,7 @@
6976

7077
file { "${mod}.load":
7178
ensure => file,
72-
path => "${mod_dir}/${mod}.load",
79+
path => "${mod_dir}/${_loadfile_name}",
7380
owner => 'root',
7481
group => $::apache::params::root_group,
7582
mode => '0644',
@@ -86,8 +93,8 @@
8693
$enable_dir = $::apache::mod_enable_dir
8794
file{ "${mod}.load symlink":
8895
ensure => link,
89-
path => "${enable_dir}/${mod}.load",
90-
target => "${mod_dir}/${mod}.load",
96+
path => "${enable_dir}/${_loadfile_name}",
97+
target => "${mod_dir}/${_loadfile_name}",
9198
owner => 'root',
9299
group => $::apache::params::root_group,
93100
mode => '0644',

spec/acceptance/default_mods_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
case fact('osfamily')
44
when 'RedHat'
5+
mod_dir = '/etc/httpd/conf.d'
56
servicename = 'httpd'
67
when 'Debian'
8+
mod_dir = '/etc/apache2/mods-available'
79
servicename = 'apache2'
810
when 'FreeBSD'
11+
mod_dir = '/usr/local/etc/apache22/Modules'
912
servicename = 'apache22'
1013
end
1114

@@ -92,4 +95,26 @@ class { 'apache':
9295
it { should be_running }
9396
end
9497
end
98+
99+
describe 'change loadfile name' do
100+
it 'should apply with no errors' do
101+
pp = <<-EOS
102+
class { 'apache': default_mods => false }
103+
::apache::mod { 'auth_basic':
104+
loadfile_name => 'zz_auth_basic.load',
105+
}
106+
EOS
107+
# Run it twice and test for idempotency
108+
apply_manifest(pp, :catch_failures => true)
109+
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
110+
end
111+
112+
describe service(servicename) do
113+
it { should be_running }
114+
end
115+
116+
describe file("#{mod_dir}/zz_auth_basic.load") do
117+
it { should be_file }
118+
end
119+
end
95120
end

0 commit comments

Comments
 (0)