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

Allow apache::mod to specify module id and path #445

Merged
merged 1 commit into from
Nov 8, 2013
Merged
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
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