Sha256: f5bb3245c8fdd1eca7545646776050c1cc60b2c51581dcf1fb0d51327944b11c

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

require 'puppet/provider/a2mod'

Puppet::Type.type(:a2mod).provide(:redhat, :parent => Puppet::Provider::A2mod) do
  desc "Manage Apache 2 modules on RedHat family OSs"

  commands :apachectl => "apachectl"

  confine :osfamily => :redhat
  defaultfor :osfamily => :redhat

  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
      @modpath = "/etc/httpd/mod.d"
    end
  end

  self.preinit

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

  def destroy
    File.delete(modfile)
  end

  def self.instances
    modules = apachectl("-M").lines.collect { |line|
      m = line.match(/(\w+)_module \(shared\)$/)
      m[1] if m
    }.compact

    modules.map do |mod|
      new(
        :name     => mod,
        :ensure   => :present,
        :provider => :redhat
      )
    end
  end

  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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
freighthop-0.6.1 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.6.0 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.5.2 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.5.1 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.5.0 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.4.1 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.4.0 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.3.3 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.3.2 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.3.1 modules/apache/lib/puppet/provider/a2mod/redhat.rb
freighthop-0.3.0 modules/apache/lib/puppet/provider/a2mod/redhat.rb