Ask Your Question

Append element to an array based on condition.

asked 2018-02-01 03:22:37 -0600

ArVincentr gravatar image


I am having trouble to achieve the following. based on the value of a variable I would like to add an extra directory to an array definition. the trigger variable is called $rdbdir


$rdbdir = 'none'

$dirs = [




if $rdbdir != 'none' { $dirs << $rdbdir }

the idea is to provide an extra value at node level. for example $rdbdir: zzz. would append /zzz to the array.

puppet run returns Error 500 on SERVER: Server Error: This 'if' statement has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form)

Any idea ?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-01 05:25:30 -0600

ArVincentr gravatar image

Variables cannot be modified once defined so the solution was to use an alternate variable in case rdbdir != 'none'

edit flag offensive delete link more


would you mind posting the code?

Soumyadip gravatar imageSoumyadip ( 2018-03-27 13:14:34 -0600 )edit

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-02-01 03:22:37 -0600

Seen: 402 times

Last updated: Feb 01