]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/lib/puppet/provider/a2mod/redhat.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / lib / puppet / provider / a2mod / redhat.rb
1 require 'puppet/provider/a2mod'
2
3 Puppet::Type.type(:a2mod).provide(:redhat, :parent => Puppet::Provider::A2mod) do
4   desc "Manage Apache 2 modules on RedHat family OSs"
5
6   commands :apachectl => "apachectl"
7
8   confine :osfamily => :redhat
9   defaultfor :osfamily => :redhat
10
11   require 'pathname'
12
13   # modpath: Path to default apache modules directory /etc/httpd/mod.d
14   # modfile: Path to module load configuration file; Default: resides under modpath directory
15   # libfile: Path to actual apache module library. Added in modfile LoadModule
16
17   attr_accessor :modfile, :libfile
18   class << self
19     attr_accessor :modpath
20     def preinit
21       @modpath = "/etc/httpd/mod.d"
22     end
23   end
24
25   self.preinit
26
27   def create
28     File.open(modfile,'w') do |f|
29       f.puts "LoadModule #{resource[:identifier]} #{libfile}"
30     end
31   end
32
33   def destroy
34     File.delete(modfile)
35   end
36
37   def self.instances
38     modules = apachectl("-M").lines.collect { |line|
39       m = line.match(/(\w+)_module \(shared\)$/)
40       m[1] if m
41     }.compact
42
43     modules.map do |mod|
44       new(
45         :name     => mod,
46         :ensure   => :present,
47         :provider => :redhat
48       )
49     end
50   end
51
52   def modfile
53     modfile ||= "#{self.class.modpath}/#{resource[:name]}.load"
54   end
55
56   # Set libfile path: If absolute path is passed, then maintain it. Else, make it default from 'modules' dir.
57   def libfile
58     libfile = Pathname.new(resource[:lib]).absolute? ? resource[:lib] : "modules/#{resource[:lib]}"
59   end
60 end