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 custom library paths and module identifier names #97

Merged
merged 4 commits into from
Oct 10, 2012
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
17 changes: 14 additions & 3 deletions lib/puppet/provider/a2mod/redhat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
confine :osfamily => :redhat
defaultfor :osfamily => :redhat

attr_accessor :modfile
require 'pathname'

# modpath: Path to default apache modules directory /etc/httpd/mod.d
# modfile: Path to module load configuration file; Default: resides under modpath directory
# libfile: Path to actual apache module library. Added in modfile LoadModule

attr_accessor :modfile, :libfile
class << self
attr_accessor :modpath
def preinit
Expand All @@ -16,7 +22,7 @@ def preinit

def create
File.open(modfile,'w') do |f|
f.puts "LoadModule #{resource[:name]}_module modules/#{resource[:lib]}"
f.puts "LoadModule #{resource[:identifier]} #{libfile}"
end
end

Expand All @@ -25,7 +31,7 @@ def destroy
end

def exists?
File.exists?(modfile) and File.read(modfile).match(resource[:lib])
File.exists?(modfile) and File.read(modfile).match(libfile)
end

def self.instances
Expand All @@ -47,4 +53,9 @@ def self.instances
def modfile
modfile ||= "#{self.class.modpath}/#{resource[:name]}.load"
end

# Set libfile path: If absolute path is passed, then maintain it. Else, make it default from 'modules' dir.
def libfile
libfile = Pathname.new(resource[:lib]).absolute? ? resource[:lib] : "modules/#{resource[:lib]}"
end
end
10 changes: 9 additions & 1 deletion lib/puppet/type/a2mod.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Puppet::Type.newtype(:a2mod) do
@doc = "Manage Apache 2 modules on Debian and Ubuntu"
@doc = "Manage Apache 2 modules"

ensurable

Expand All @@ -15,6 +15,14 @@

defaultto { "mod_#{@resource[:name]}.so" }
end

newparam(:identifier) do
desc "Module identifier string used by LoadModule. Default: module-name_module"

# http://httpd.apache.org/docs/2.2/mod/module-dict.html#ModuleIdentifier

defaultto { "#{resource[:name]}_module" }
end

autorequire(:package) { catalog.resource(:package, 'httpd')}

Expand Down
21 changes: 14 additions & 7 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@
$lib = $mod_lib
}

$mod_identifiers = $apache::params::mod_identifiers
$mod_identifier = $mod_identifiers[$mod]
if "${mod_identifier}" {
$identifier = $mod_identifier
}

if $package_REAL {
package { $package_REAL:
ensure => present,
require => Package['httpd'],
before => A2mod[$mod],
ensure => present,
require => Package['httpd'],
before => A2mod[$mod],
}
}

a2mod { $mod:
ensure => present,
lib => $lib,
require => Package['httpd'],
notify => Service['httpd'],
ensure => present,
lib => $lib,
identifier => $identifier,
require => Package['httpd'],
notify => Service['httpd'],
}
}
5 changes: 5 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@
'python' => 'mod_python',
'ssl' => 'mod_ssl',
'wsgi' => 'mod_wsgi',
'shibboleth' => 'shibboleth',
}
$mod_libs = {
'php5' => 'libphp5.so',
}
$mod_identifiers = {
'shibboleth' => 'mod_shib',
}
} elsif $::osfamily == 'debian' {
$user = 'www-data'
$group = 'www-data'
Expand All @@ -78,6 +82,7 @@
'wsgi' => 'libapache2-mod-wsgi',
}
$mod_libs = {}
$mod_identifiers = {}
} else {
fail("Class['apache::params']: Unsupported operatingsystem: $operatingsystem")
}
Expand Down