For anyone interested in how I got around this, I ended up creating a custom function and placed it inside modules/<module>/lib/puppet/parser/functions. The function essentially uses hiera to lookup my 'interfaces' key in the YAML and loops through it to find if 10G has been set for any interfaces. Similar to:
module Puppet::Parser::Functions newfunction(:is_10G, :type => :rvalue) do |arg| result = false Puppet::Parser::Functions.autoloader.loadall function_hiera(['interfaces']).each { |key, value| if $value['10G'] result = true break end end result end end With the above function, I can call is_10G() from anywhere to find out if any interface is 10G capable. Next step is probably to create facts based on ethtool to tell me if an interface is 10G capable, as opposed to setting it statically in hiera. - Gonzalo On Fri, Oct 11, 2013 at 9:53 AM, Gonzalo Servat <gser...@gmail.com> wrote: > Hi All, > > In hiera, I have something like: > > interfaces: > nic1: > 10G: true > ip: x.x.x.x > netmask: x.x.x.x > nic2: > ip: x.x.x.x > netmask: x.x.x.x > > This hiera config is used to build the interface configuration files. Now, > if a server has at least ONE NIC with 10G == true, I want to make a few > more changes to that machine. It can happen from various manifests so > preferably I'd like a global boolean or some way to say "if $10G { ... }". > > I could have a root setting called "10G: true" and I can just do: > > if hiera('10G', false) { > // do stuff > } > > ... but I'd like to avoid having to duplicate the 10G setting in the hiera > file. > > The logic I had in mind was to go through hiera('interfaces') and, if any > NIC has 10G == true, then set a global "boolean" that I can reference from > any manifest. > > I thought I could write a custom fact of some sort that calls hiera(), but > since the fact gets generated on the client and hiera is on the server... > > Any ideas? > > Thanks in advance. > Gonzalo > -- 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 puppet-users+unsubscr...@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.