Ask Your Question
0

Append element to an array based on condition.

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

ArVincentr gravatar image

Hello,

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

params.pp

$rdbdir = 'none'

$dirs = [

'/var/run/aaa',
'/var/log/aaa',
'/var/lib/aaa',
'/etc/aaa',

]

config.pp

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 ?

Thx

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Comments

would you mind posting the code?

Soumyadip gravatar imageSoumyadip ( 2018-03-27 13:14:34 -0500 )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

Stats

Asked: 2018-02-01 03:22:37 -0500

Seen: 104 times

Last updated: Feb 01