(#18730) Add a Hiera node terminus #1414

Closed
wants to merge 1 commit into
from

5 participants

@dalen

Allows using hiera as node terminus instead of doing something like
include hiera_array('puppet::classes') in site.pp.

It uses the keys puppet::classes, puppet::parameters &
puppet::environment.

@dalen

This is missing tests so far. But I'd also like some feedback on the choice of key names.

@hunner
Puppet member

One comment is that you necessarily need a scope object, like https://gist.github.com/hunner/4773601. I like that you can declare the environment!

@puppetcla

CLA Signed by dalen on 2012-07-17 21:00:00 -0700

@jpoppe

I love the idea! Will try to test it.

@hlindberg hlindberg commented on the diff Jun 10, 2013
lib/puppet/indirector/node/hiera.rb
@@ -0,0 +1,19 @@
+require 'hiera'
+require 'puppet/node'
+require 'puppet/indirector/hiera'
+
+class Puppet::Node::Hiera < Puppet::Indirector::Hiera
+ desc 'Get node information from Hiera. Queries the keys "environment", "classes" and "parameters".'
+
+ def find(request)
+ facts = Puppet::Node::Facts.indirection.find(request.key)
+ node = Puppet::Node.new(
+ request.key,
+ :environment => hiera.lookup('environment', request.environment.name.to_s, facts.values),
@hlindberg
hlindberg added a line comment Jun 10, 2013

why is "facts.values" passed as indication that hiera should return whatever it found bound at the key? (IIRC, hiera.lookup's last parameter is :array or :hash to enforce an array or a hash, if not one of those symbols it will return whatever was looked up. facts.values is a collection of facts...
Confused.

@dalen
dalen added a line comment Jun 13, 2013

facts.values is the third argument to lookup which is the scope. The method definition of lookup is lookup(key, default, scope, order_override=nil, resolution_type=:priority)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dalen dalen (#18730) Add a Hiera node terminus
Allows using hiera as node terminus instead of doing something like
include hiera_array('classes') in site.pp.

It uses the keys classes, parameters & environment.
baa01f2
@zaphod42

@dalen thanks for submitting this. I'm going to close this down since it looks like we aren't actually going anywhere with it, but I would encourage you to ship this in a puppet module if you think it still has value.

@zaphod42 zaphod42 closed this Oct 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment