Ask Your Question

Setting default value for a variable, in case lookup doesn't return anything

asked 2018-06-15 05:10:47 -0600

monalsharma gravatar image


I have a code which work with puppet version 3 to set Password min length settings for the value 8 if Hiera can't find a value in data

$_passlen = hiera('entos_generic_harden::accounts::passlen',8)

The same code am migrating with Puppet version 4 as follows

$_passlen = lookup('entos_generic_harden::accounts::passlen', default_value => 8)

while applying the module am getting an error as below. Error: /Stage[main]/Entos_generic_harden::Accounts/Augeas[/etc/login.defs]: Could not evaluate: missing string argument 2 for set

kindly suggest how to set a default value on Puppet 4 version if Hiera can't find a value in data.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-15 07:10:38 -0600

Mr_Sharma gravatar image

Hi Monal,

I think instead of using the lookup function we can rely on automatic parameter lookup which is quite simpler than this. Hence instead of using the above function you can do something similar to following:

class entos_generic_harden::accounts (
$passlen = 8,
$other   = "newvalue"
) {
//Resource definition

and correspondingly you need to define the parameter value in your heira data yaml as:

entos_generic_harden::accounts::passlen: 8

Couple of references given below:

Hope this helps.

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: 2018-06-15 05:10:47 -0600

Seen: 75 times

Last updated: Jun 15