Search code examples
puppet

Parameter mapping with Hiera


Is it possible to map hiera parameter to another one?

For example, if in hiera there is already a parameter "person::shoe::size" , and puppet module "other_module" needs to lookup parameter like this: hiera(person_shoe_size).

Is it possible to tell hiera that parameter "person_shoe_size" is the same thing as "person::shoe::size", and that hiera(person_shoe_size) should actually be mapped to hiera(person::shoe::size)?


Solution

  • Yes, you can do a hiera lookup inside of your value.

    person::shoe::size: "7"
    person_shoe_size: "%{hiera('person::shoe::size')}"
    

    Looking up either would return 7. You can also do something like this:

    hostname: "cool-hostname"
    module::fully_qualified_name: "%{hiera('hostname')}.domain.tld"
    

    Here, the fully_qualified_name parameter will have a value of cool-hostname.domain-tld.