Ask Your Question
1

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 maxscalf1.mylabserver.com, hiera will look for yaml files in following order... maxscalf1.mylabserver.com.yaml (if nothing is found here) then looks for maxscalf1.mylabserver.yaml(if nothing is found here) look for maxscalf1.yaml ...is 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
[main]
    certname = maxscalf1.mylabserver.com
    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 = maxscalf1.mylabserver.com
    user  = pe-puppet
    group = pe-puppet
    archive_files = true
    archive_file_server = maxscalf1.mylabserver.com

[master]
    certname = maxscalf1.mylabserver.com
    ca_name = 'Puppet CA generated on maxscalf1.mylabserver.com 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

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



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

:yaml:
# 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
---
domain_name: common.maxscalf1.com
api_key: common_api_key
[root@maxscalf1 hieradata]# cat production.yaml
---
domain_name: prod.maxscalf1.com
api_key: prod_api_key
[root@maxscalf1 hieradata]# cat developlment.yaml
---
domain_name: dev.maxscalf1.com
api_key: dev_api_key
[root@maxscalf1 hieradata]# cat RedHat.yaml
---
domain_name: redhat.maxscalf1.com
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 maxscalf1.mylabserver.com.yaml
[root@maxscalf1 node]#
[root@maxscalf1 node]# cat maxscalf1.mylabserver.com.yaml
---
hierademo::domain_name: parameterdemo.mylabserver.com
domain_name: cert_name.maxscalf1.mylabserver.com
api_key: cert_name_api_key
[root@maxscalf1 node]#
[root@maxscalf1 node]# hiera domain_name clientcert=maxscalf1.mylabserver.com
cert_name.maxscalf1.mylabserver.com
[root@maxscalf1 node]#
[root@maxscalf1 node]# hiera domain_name clientcert=maxscalf1.mylabserver
common.maxscalf1.com
[root@maxscalf1 node]#
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

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: https://docs.puppetlabs.com/puppet/latest/reference/langnodedefinitions.html#matching).

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
0

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

max scalf gravatar image

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

hello,

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

https://linuxacademy.com/community/po...

edit flag offensive delete link more

Comments

1

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

Stats

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

Seen: 159 times

Last updated: Jun 25 '15