Hiera lookup : wrong behavior

asked 2017-02-07 08:20:05 -0600

craymore gravatar image

Hello dear puppeteers !

( running puppet 4.8.1 here )

Let's say I have two YAML files build as per the following specs

file1.yaml

entry:
    version: "%{hiera('package-version')}"

file2.yaml

package-version: "1.2.1"

Nothing fancy here, but when puppet tries to build the catalog, the following message pops-up :

[...] Could not find data item 1.2.1 in any Hiera data file and no default supplied at [...]

So, apparently hiera retrieves the value but then tries to lookup it up elsewhere using it as key ... what am doing wrong here ?

Thanks beforehand for any answer

edit retag flag offensive close merge delete

Comments

Do you have file1.yaml and file2.yaml correctly in your hierarchy? That error makes me think that you have file1.yaml but not file2.yaml being selected. You could copy package-version into file1 and make sure your syntax still works, otherwise you need to look into how your hierarchy populated

DarylW gravatar imageDarylW ( 2017-02-07 09:06:49 -0600 )edit
DarylW gravatar imageDarylW ( 2017-02-07 09:08:28 -0600 )edit

All the files are correctly referenced in the hierarchy. $> puppet lookup --node <my node=""> --merge deep --explain --debug package-version [...] Debug: hiera(): Found package-version in common Error: Could not run: Hiera type mismatch for key 'package-version: expected Hash and got String

craymore gravatar imagecraymore ( 2017-02-07 11:20:31 -0600 )edit

I wonder if you need to use alias instead of hiera, I think hiera only returns a string... https://docs.puppet.com/hiera/3.2/variables.html#the-alias-lookup-function

DarylW gravatar imageDarylW ( 2017-02-07 11:45:25 -0600 )edit

"[...] I think hiera only returns a string [...]" But then why does it give this message then ? ( "expected Hash and got String" )

craymore gravatar imagecraymore ( 2017-02-08 03:23:48 -0600 )edit