puppet Evaluation Error: Cannot reassign variable

Viewed 19

We are trying to override the the value assigned to the variable in the puppet manifest. Below is the piece of the line from puppet manifest :

39  $java_opts_nodeconfig_extra = '-XX:+ScavengeBeforeFullGC -verbose:gc'
40
41  if $jdk_version =~ /^1.8\.\d+\_/ {
42    $java_opts_nodeconfig_extra = "-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails ${java_opts_nodeconfig_extra}"
43  }

And puppet script fails with below error, my use case is if the JDK version is 1.8.x, then override the value and assign to the same variable otherwise the original value assigned to the variable.

Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Cannot reassign variable '$java_opts_snippet_nodeconfig_extra' (file:/puppet/modules/acme/manifests/acme_manager.pp, line: 42, column: 41)

How do we solve this ?

1 Answers

Never mind, based on this https://codeburst.io/puppet-code-by-example-part-2-b1099b4ff9a1, looks like we cannot reassign. So , we used other way by means of using "Case" statement.

Related