Last active
December 11, 2015 06:39
-
-
Save dalen/4560765 to your computer and use it in GitHub Desktop.
Puppet Hiera node terminus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'hiera' | |
require 'puppet/node' | |
require 'puppet/indirector/hiera' | |
class Puppet::Node::Hiera < Puppet::Indirector::Hiera | |
desc "Get node information from Hiera. Gets classes using a array lookup on the puppet::classes key." | |
include Puppet::Util | |
# Look for external node definitions. | |
def find(request) | |
node = Puppet::Node.new(request.key) | |
scope = Puppet::Node::Facts.indirection.find(request.key, :environment => request.environment).values | |
scope['environment'] = hiera.lookup('puppet::environment', nil, scope) || request.environment.name.to_s | |
node.environment = scope['environment'] | |
node.classes = hiera.lookup('puppet::classes', [], scope, nil, :array) | |
node.parameters = hiera.lookup('puppet::parameters', {}, scope, nil, :hash) | |
node.fact_merge | |
node | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment