Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODULES-956 Added loadfile_name parameter to apache::mod. #737

Merged
merged 1 commit into from
May 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use the $_loadfile_name here instead of the ${mod}.load instead as that is the file we are taking action against?

ensure => file,
path => "${mod_dir}/${mod}.load",
path => "${mod_dir}/${_loadfile_name}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyberious, We keep "${mod}.load" as name, but fix the path. In file, path defaults to name/title, but we're setting all explicitly.

That way we can always canonically refer to the file under a known name, throughout the entire module. And at the same time we have a different path, if we need one.

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