Ask Your Question

Hiera function chop off yaml file ?

asked 2015-06-22 13:45:30 -0500

max scalf gravatar image

updated 2015-06-24 00:35:52 -0500

GregLarkin gravatar image

Hello all,

I am very much new to puppet so please bare with me, below are my details with regrads to hiera....i was told that hiera will make passes, if my cert name is, hiera will look for yaml files in following order... (if nothing is found here) then looks for maxscalf1.mylabserver.yaml(if nothing is found here) look for maxscalf1.yaml this true...i ltried out the below sample but that does not seem to be the case but i was told that hiera will do something similar compared to node defination in site.pp(if exact certname is not found or no regex is found the look it will start chopping stuff or nothing is found look at defaults)

[root@maxscalf1 manifests]# cat /etc/puppetlabs/puppet/puppet.conf
    certname =
    dns_alt_names = puppet
    vardir = /var/opt/lib/pe-puppet
    logdir = /var/log/pe-puppet
    rundir = /var/run/pe-puppet
    basemodulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
    server =
    user  = pe-puppet
    group = pe-puppet
    archive_files = true
    archive_file_server =

    certname =
    ca_name = 'Puppet CA generated on at 2015-06-20 07:05:36 +0000'
    reports = console,puppetdb
    node_terminus = console
    ssl_client_header = SSL_CLIENT_S_DN
    ssl_client_verify_header = SSL_CLIENT_VERIFY
    storeconfigs = true
    storeconfigs_backend = puppetdb

    report = true
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    graph = true
    pluginsync = true
    environment = production
[root@maxscalf1 manifests]#

[root@maxscalf1 puppet]# cat hiera.yaml
  - yaml
  - "%{::osfamily}"
  - "node/%{clientcert}"
  - common

# datadir is empty here, so hiera uses its defaults:
# - /var/lib/hiera on *nix
# - %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
  :datadir: /etc/puppetlabs/puppet/hieradata
[root@maxscalf1 puppet]#
[root@maxscalf1 puppet]# cd hieradata/
[root@maxscalf1 hieradata]#
[root@maxscalf1 hieradata]# ls -ltr
total 20
-rw-r--r-- 1 root root   65 Jun 21 03:43 common.yaml
-rw-r--r-- 1 root root   59 Jun 21 03:44 developlment.yaml
-rw-r--r-- 1 root root   61 Jun 21 03:45 production.yaml
drwxr-xr-x 2 root root 4096 Jun 21 04:19 node
-rw-r--r-- 1 root root   65 Jun 21 04:28 RedHat.yaml
[root@maxscalf1 hieradata]# cat common.yaml
api_key: common_api_key
[root@maxscalf1 hieradata]# cat production.yaml
api_key: prod_api_key
[root@maxscalf1 hieradata]# cat developlment.yaml
api_key: dev_api_key
[root@maxscalf1 hieradata]# cat RedHat.yaml
api_key: redhat_api_key
[root@maxscalf1 hieradata]#
[root@maxscalf1 hieradata]# cd node/
[root@maxscalf1 node]# ls -ltr
total 4
-rw-r--r-- 1 root root 137 Jun 21 04:19
[root@maxscalf1 node]#
[root@maxscalf1 node]# cat
api_key: cert_name_api_key
[root@maxscalf1 node]#
[root@maxscalf1 node]# hiera domain_name
[root@maxscalf1 node]#
[root@maxscalf1 node]# hiera domain_name clientcert=maxscalf1.mylabserver
[root@maxscalf1 node]#
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-24 00:42:40 -0500

GregLarkin gravatar image

I have never heard of Hiera performing fuzzy hostname matching like the node definitions do (cf:

Can you provide a reference document citing the same functionality in Hiera? I could not find one, and as far as I know, Hiera will only perform a strict lookup based on the hierarchy that you define.

edit flag offensive delete link more

answered 2015-06-25 11:05:43 -0500

max scalf gravatar image

updated 2015-06-25 11:35:39 -0500


i am not saying i saw it anywhere in doc, but i had asked the same question below and that is what was said

edit flag offensive delete link more



Unfortunately, "Anthony J" is incorrect. Hiera does not search for YAML files the way that node definition matching is done as referenced in my answer. Unless you implement that fuzzy matching using custom facts and extra levels in your hierarchy, Hiera will only look for <clientcert>.yaml.

GregLarkin gravatar imageGregLarkin ( 2015-06-25 11:15:30 -0500 )edit

Feel free to point that user to this page if he wants to comment here for further clarification.

GregLarkin gravatar imageGregLarkin ( 2015-06-25 11:16:40 -0500 )edit

Thank you Gerg, i tested that and that is what i found as well but wanted to make sure and have a second opinion..

max scalf gravatar imagemax scalf ( 2015-06-25 11:36:57 -0500 )edit

Sounds good, and glad you got that sorted out!

GregLarkin gravatar imageGregLarkin ( 2015-06-25 12:28:09 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-22 13:45:30 -0500

Seen: 156 times

Last updated: Jun 25 '15