puppethiera

How to setup a default hiera lookup value


I am setting up my Puppet code using Hiera such that if a value is not found in Hiera, it assigns a default value to it. I am not getting the desired results and wanted to know how others did it :

lookup( <NAME>, [<VALUE TYPE>], [<MERGE BEHAVIOR>], [<DEFAULT VALUE>] )

I think I found the answer https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php , will try it shortly

lookup({"name" => "some::thing", "default_value" => "default"})

Solution

  • The solution that worked for me was :

    $myvar1 = lookup( { "name" => "myvar1", "default_value" => "default" } )