Try the structured facts. $facts['networking']['network'] is probably somewhat indeterministic, but if your interface names are predictable, then $facts['networking']['interfaces']['ens192']['network'] (or 'eth0' or whatever) could conceivably be the value you need.
Having tried to fight with this before, however, I went with an external fact. I don't need the network so much as I need the datacenter and I just create the file `/etc/facter/facts.d/datacenter` in my templates or during provisioning, so I never need to deal with some wacky new network that isn't correlated to a datacenter until I touch some code again. Something like that might be helpful even if you can get the structured fact right, as the provisioning process is often a better spot to insert such values. Rob Nelson [email protected] On Thu, Apr 13, 2017 at 12:21 PM, Peter K <[email protected]> wrote: > This network lookup is simple and works well...but only on some clients > because they have more than one network interface: > hiera.yaml: > --- > :hierarchy: > - "%{::trusted.certname}" > - "%{::network}" > - common > > It fails on some machines because they have docker virtual interfaces and > instead return a network name like 172.0.0.0 instead of the one I want: > 10.1.1.0. > It seems the lookup just picks the first interface listed in the > ::networking array. > Are there any other methods to do lookups based on the network? I want to > match the same network that puppet is working on. > > My experience is I can't easily parse the hiera lookup for ::networking > (asked here > <https://groups.google.com/forum/#!searchin/puppet-users/hiera$20by$20network%7Csort:relevance/puppet-users/JXVV79GbuvA/z2lNPubRR-wJ>) > but maybe I can with hiera5 with globs > <https://docs.puppet.com/puppet/4.9/hiera_config_yaml_5.html>. > Thx, > -peter > > -- > 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/0593fc69-c51e-4176-a4c8-c28840ac59a4%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/0593fc69-c51e-4176-a4c8-c28840ac59a4%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAC76iT968ybMvaFgB3UZ_1BySv3YjOFvriXPzwYVUJwqtCiSyg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
