Ask Your Question
0

Hiera lookup question

asked 2015-10-06 16:02:48 -0500

sheshi gravatar image

updated 2015-10-06 16:08:19 -0500

llowder gravatar image

I was expecting a value of '1522' when I do a hiera lookup of db_port in my manifest file. To my surprise, I see the value '1521' being set. I am using Puppet in a standalone mode.

Can someone please tell me what is that I am doing wrong?

My hiera.yaml:

---
:backends:
  - yaml

:hierarchy:
  - defaults
  - pt_customizations
  - pt_deployment
  - pt_configuration
  - global

:yaml:
  :datadir: /etc/puppet/data

pt_customizations.yaml

--
db_port: 1522

pt_configuration.yaml

--
db_port:1521

Command line: puppet apply -e "notice(hiera('db_port'))" --debug

Debug: hiera(): Hiera YAML backend starting  
Debug: hiera(): Looking up db_port in YAML backend 
Debug: hiera(): Looking for data source defaults  
Debug: hiera(): Looking for data source pt_customizations  
Debug: hiera(): Looking for data source pt_deployment  
Debug: hiera(): Looking for data source pt_configuration  
Debug: hiera(): Found db_port in pt_configuration Notice: Scope(Class[main]): 1521

Why is the Hiera lookup skipping the db_port value found in pt_customizations and going to pt_configuration instead? Shouldn't it find it in pt_customizations and return that value? Someone please explain.

Thanks

-Sheshi

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-10-06 16:39:11 -0500

lupin gravatar image

Have you check your ptcustomizations.yaml for any invisible characters? od -c <your>.yaml On both files the line for dbport should be identical except for extra white-space that you had on your pt_customizations.

What's the output of hiera 'db_port' -d ?

edit flag offensive delete link more
-1

answered 2015-10-06 18:55:56 -0500

sheshi gravatar image

Thanks Lupin,

Here is the output

[root@]# od -c pt_customizations.yaml 0000000 - - \n d b _ p o r t : " 1 5 2 0000020 2 " \n 0000023

[root@]# hiera 'dbport' -d -c /etc/puppet/hiera.yaml DEBUG: Tue Oct 06 23:47:30 +0000 2015: Hiera YAML backend starting DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking up dbport in YAML backend DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking for data source defaults DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking for data source psftcustomizations DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking for data source psftunixsystem DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking for data source psftdeployment DEBUG: Tue Oct 06 23:47:30 +0000 2015: Looking for data source psftconfiguration DEBUG: Tue Oct 06 23:47:30 +0000 2015: Found dbport in psft_configuration 1521

edit flag offensive delete link more

Comments

You should add this as a comment to Lupin's answer, and please format your code as code (Hit the 'code' button to indent it so that Markdown will recognize it as code).

stefanlasiewski gravatar imagestefanlasiewski ( 2015-10-06 19:14:42 -0500 )edit

sheshi, I cannot edit your post, can you please edit it so it will be clearer. Is there a difference on output of your `od -c` between pt_customizations and pt_configuration yaml file for the db_port line?

lupin gravatar imagelupin ( 2015-10-06 19:40:38 -0500 )edit

Thanks Lupin. I found the issue. The issue is related to the 'dashes' at the top of the yaml file. I had double 'dash' instead of triple 'dash' in my customizations.yaml file.

sheshi gravatar imagesheshi ( 2015-10-06 20:44:20 -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-10-06 16:02:48 -0500

Seen: 317 times

Last updated: Oct 06 '15