From 9cc8f3dec01fcb0cef11a44166d84f3d4b2b442e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 23 May 2014 13:54:45 -0400 Subject: [PATCH] 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. --- README.md | 4 ++++ manifests/mod.pp | 25 ++++++++++++++++--------- spec/acceptance/default_mods_spec.rb | 25 +++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fd5cb87dc..d5b82e935 100644 --- a/README.md +++ b/README.md @@ -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'. diff --git a/manifests/mod.pp b/manifests/mod.pp index 9d65bd91f..968bd3eb4 100644 --- a/manifests/mod.pp +++ b/manifests/mod.pp @@ -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') @@ -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 @@ -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', @@ -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', diff --git a/spec/acceptance/default_mods_spec.rb b/spec/acceptance/default_mods_spec.rb index 2b8b409e3..c7f875560 100644 --- a/spec/acceptance/default_mods_spec.rb +++ b/spec/acceptance/default_mods_spec.rb @@ -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 @@ -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