Ask Your Question

Hiera : correct lookup way

asked 2017-01-03 09:05:01 -0600

craymore gravatar image

updated 2017-01-03 09:05:53 -0600

Hello all,

I am currently reviewing some Hiera configuration file(s) and came across some elements which I would need advices about.

Here's a Hiera configuration example :

    service_name: svc-id-tag
      c_url: "%{hiera('compliance_url')}"

both svc-id-tag and compliance_url are Hiera keys located in another YAML configuration file and both ways actually work to retrieve the value.

But what is the best ( recommended ) way to perform lookups ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-01-03 09:18:38 -0600

DarylW gravatar image

updated 2017-01-03 09:18:57 -0600

I would perform all of the lookups using the hiera lookup function (basically as you are doing in c_url)

The hiera() lookup function

The hiera() lookup function performs a Hiera lookup, using its input as the lookup key. The result of the lookup must be a string; any other result will cause an error.

This can be very powerful in Hiera’s data sources. By storing a fragment of data in one place and then using sub-lookups wherever it needs to be used, you can avoid repetition and make it easier to change your data. wordpress::database_server: "%{hiera('instances::mysql::public_hostname')}"

The value looked up by the hiera() function may itself contain a hiera() lookup. (The function will detect any circular lookups and fail with an error instead of looping infinitely.)

Note: Using recursive lookups in Hiera’s config file is untested and can potentially cause infinite recursion. (See HI-220.) You should only use the hiera() function in data sources.

edit flag offensive delete link more

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: 2017-01-03 09:05:01 -0600

Seen: 144 times

Last updated: Jan 03 '17