Skip to content

Commit

Permalink
Merge pull request #737 from mhaskel/rename_mod_load
Browse files Browse the repository at this point in the history
MODULES-956 Added loadfile_name parameter to apache::mod.
  • Loading branch information
Ashley Penney committed May 28, 2014
2 parents 81069bc + 9cc8f3d commit e66c783
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ Sets the amount of time the server will wait for subsequent requests on a persis

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

#####`loadfile_name`

Sets the file name for the module loadfile. Should be in the format *.load. This can be used to set the module load order.

#####`log_level`

Changes the verbosity level of the error log. Defaults to 'warn'. Valid values are 'emerg', 'alert', 'crit', 'error', 'warn', 'notice', 'info', or 'debug'.
Expand Down
25 changes: 16 additions & 9 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
define apache::mod (
$package = undef,
$package = undef,
$package_ensure = 'present',
$lib = undef,
$lib_path = $::apache::params::lib_path,
$id = undef,
$path = undef,
$loadfiles = undef,
$lib = undef,
$lib_path = $::apache::params::lib_path,
$id = undef,
$path = undef,
$loadfile_name = undef,
$loadfiles = undef,
) {
if ! defined(Class['apache']) {
fail('You must include the apache base class before using any apache defined resources')
Expand Down Expand Up @@ -39,6 +40,12 @@
$_id = "${mod}_module"
}

if $loadfile_name {
$_loadfile_name = $loadfile_name
} else {
$_loadfile_name = "${mod}.load"
}

# Determine if we have a package
$mod_packages = $::apache::params::mod_packages
$mod_package = $mod_packages[$mod] # 2.6 compatibility hack
Expand Down Expand Up @@ -69,7 +76,7 @@

file { "${mod}.load":
ensure => file,
path => "${mod_dir}/${mod}.load",
path => "${mod_dir}/${_loadfile_name}",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
Expand All @@ -86,8 +93,8 @@
$enable_dir = $::apache::mod_enable_dir
file{ "${mod}.load symlink":
ensure => link,
path => "${enable_dir}/${mod}.load",
target => "${mod_dir}/${mod}.load",
path => "${enable_dir}/${_loadfile_name}",
target => "${mod_dir}/${_loadfile_name}",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
Expand Down
25 changes: 25 additions & 0 deletions spec/acceptance/default_mods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

case fact('osfamily')
when 'RedHat'
mod_dir = '/etc/httpd/conf.d'
servicename = 'httpd'
when 'Debian'
mod_dir = '/etc/apache2/mods-available'
servicename = 'apache2'
when 'FreeBSD'
mod_dir = '/usr/local/etc/apache22/Modules'
servicename = 'apache22'
end

Expand Down Expand Up @@ -92,4 +95,26 @@ class { 'apache':
it { should be_running }
end
end

describe 'change loadfile name' do
it 'should apply with no errors' do
pp = <<-EOS
class { 'apache': default_mods => false }
::apache::mod { 'auth_basic':
loadfile_name => 'zz_auth_basic.load',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end

describe service(servicename) do
it { should be_running }
end

describe file("#{mod_dir}/zz_auth_basic.load") do
it { should be_file }
end
end
end

0 comments on commit e66c783

Please sign in to comment.