How to setup a default hiera lookup value

巧了我就是萌 提交于 2019-12-12 06:00:08

问题


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"})

回答1:


The solution that worked for me was :

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



回答2:


Generally , if the value logpath is declared in hiera . Puppet manifest will pick up the value automatically .If it is not found in Hiera , then puppet agent will error out saying that value is not found .

If the value is not declared in Hiera , there is always a way where in one can declare the value in puppet manifest . if the value is not find in Puppet Hiera , then manifest is looked into for the puppet value .

As a good practice , value is declared in hiera and as well as puppet manifest .If the value is not found in Hiera , puppet will look into variable present in manifest



来源:https://stackoverflow.com/questions/44606675/how-to-setup-a-default-hiera-lookup-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!