Skip to content

Commit

Permalink
Merge pull request #445 from ptomulik/explicit_mod_id
Browse files Browse the repository at this point in the history
Allow apache::mod to specify module id and path
  • Loading branch information
Ashley Penney committed Nov 8, 2013
2 parents 02e795f + 9d19e7a commit 092f927
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
define apache::mod (
$package = undef,
$package_ensure = 'present',
$lib = undef
$lib = undef,
$lib_path = $apache::params::lib_path,
$id = undef,
$path = undef,
) {
if ! defined(Class['apache']) {
fail('You must include the apache base class before using any apache defined resources')
}

$mod = $name
#include apache #This creates duplicate resources in rspec-puppet
$lib_path = $apache::params::lib_path
$mod_dir = $apache::mod_dir

# Determine if we have special lib
$mod_libs = $apache::params::mod_libs
$mod_lib = $mod_libs[$mod] # 2.6 compatibility hack
if $lib {
$lib_REAL = $lib
$_lib = $lib
} elsif "${mod_lib}" {
$lib_REAL = $mod_lib
$_lib = $mod_lib
} else {
$lib_REAL = "mod_${mod}.so"
$_lib = "mod_${mod}.so"
}

# Determine if declaration specified a path to the module
if $path {
$_path = $path
} else {
$_path = "${lib_path}/${_lib}"
}

if $id {
$_id = $id
} else {
$_id = "${mod}_module"
}

# Determine if we have a package
$mod_packages = $apache::params::mod_packages
$mod_package = $mod_packages[$mod] # 2.6 compatibility hack
if $package {
$package_REAL = $package
$_package = $package
} elsif "${mod_package}" {
$package_REAL = $mod_package
$_package = $mod_package
}
if $package_REAL and ! defined(Package[$package_REAL]) {
# $package_REAL may be an array
package { $package_REAL:
if $_package and ! defined(Package[$_package]) {
# $_package may be an array
package { $_package:
ensure => $package_ensure,
require => Package['httpd'],
before => File["${mod_dir}/${mod}.load"],
Expand All @@ -46,7 +61,7 @@
owner => 'root',
group => $apache::params::root_group,
mode => '0644',
content => "LoadModule ${mod}_module ${lib_path}/${lib_REAL}\n",
content => "LoadModule ${_id} ${_path}\n",
require => [
Package['httpd'],
Exec["mkdir ${mod_dir}"],
Expand Down

0 comments on commit 092f927

Please sign in to comment.