Thanks. Here's a simplified version of what I ended up doing (for anyone 
searching for a similar thing):

In custom_functions/lib/puppet/parser/functions/determine_role.rb:

module Puppet::Parser::Functions
  newfunction(:determine_role, :type => :rvalue) do |args|
    # args[0] should be a fact name like clientcert or fqdn.
    hostname = lookupvar(args[0])
    matches = hostname.match(/^([^0-9.]+)[0-9.]/).captures
    role = matches[0]
    return role
  end
end

In manifests/site.pp

$role = determine_role('clientcert')

node default {
  hiera_include('classes')
}

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d416e2fd-4731-4e10-852a-f3663e61e3e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to