Hiera command line: How do I view all data in the hierarchy for a given node?

Dave F picture Dave F · Jan 7, 2015 · Viewed 8.4k times · Source

just testing out hiera and I'd like to be able to view all the available data (variable=value pairs) in the hierarchy for a given node.

My Hiera hierarchy is configured as:

---
:backends:
  - yaml
  - json
:yaml:
  :datadir: C:\Puppet\hieradata
:hierarchy: 
  - "Env/%{::env}"
  - common

I can run the following to return node1's value for 'some-common' variable :

>hiera some-common ::env=node1
data

What I'd like to be able to see is all the variable=value pairs available to node1 in the hierarchy, is this possible? Thanks

Answer

Tombart picture Tombart · Apr 17, 2015

I'm afraid this is not possible. Closest thing you could do is dump facts for specific node:

facter -y > node.yml

And then use them for look for specific keys:

hiera -y node.yml my_class:arg -d

this way you will be able to access Hiera keys based on operating system, domain, etc. (depends on your hierarchy defined in hiera.yaml).

Yet another option is to ssh into puppet master node. And use puppet lookup (should be available since Puppet 4). lookup is using by default Hiera backend (again requires hiera.yaml config file).

puppet lookup resolv_conf::nameservers --node mynode.example.net

or more verbose version:

puppet lookup resolv_conf::nameservers --merge deep --environment production --explain --node mynode.example.net