Skip to content

Instantly share code, notes, and snippets.

@jfryman
Last active December 21, 2015 13:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfryman/6310732 to your computer and use it in GitHub Desktop.
Save jfryman/6310732 to your computer and use it in GitHub Desktop.
AutoLoader
# autoloader.pp
class nagios::autoload_helpers {
$helpers = get_nagios_helpers()
case $::puppetversion {
/^3/: { include $helpers }
default: {
nagios::autoload_helpers::import_shim { $helpers: }
}
}
}
module Puppet::Parser::Functions
newfunction(:get_nagios_helpers,
:type => :rvalue,
:doc => "Grab all modules that have nagios helpers for import") do
module_path = File.expand_path('..',
Puppet::Module.find('nagios',compiler.environment.to_s).path)
helpers = Dir["#{module_path}/**/nagios/helpers.pp"].map do |d|
"#{d.split('/')[-4]}::nagios::helpers"
done
helpers
end
end
include nagios::autoload_helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment