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
With node-specific variables, each node gets a customized set of paths to data. The hierarchy is always the same. After Hiera replaces the variables to make a list of concrete data sources, it checks those data sources in the order they were written.
The hierarchy is always the same. After Hiera replaces the variables to make a list of concrete data sources, it checks those data sources in the order they were written.
Hiera looks up data by following a hierarchy — an ordered list of data sources. Hierarchies are configured in a hiera.yaml configuration file. Each level of the hierarchy tells Hiera how to access some kind of data source. A hierarchy is usually organized like this:
Use hierarchyidas a data type to create tables with a hierarchical structure, or to describe the hierarchical structure of data that is stored in another location. Use the hierarchyid functionsin Transact-SQL to query and manage hierarchical data. Key Properties of hierarchyid
I found another workaround - you can add top level key to your yaml data:
node-data:
hosts:
- localhost:3367
- company.com
dns: 8.8.8.8
policy:
retries: 3
timeout: 5
and do puppet lookup with merge for this top level key, e.g.:
puppet lookup --merge hash/deep node_data
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With