Issue #9848 has been updated by Nick S.

I'd like to point out that this effect can cause very nasty things to happen, 
in the same way that any interpolation of an undefined variable can be. For an 
example, see this thread on the puppet-users list:  [Is paramater ordering 
non-deterministic?](https://groups.google.com/forum/#!topic/puppet-users/6ojC0iAsvz0).

See also the similar (fixed) bugs #6534, #5061, and the suggestion that there 
should be a "strict" pragma in #4408.

Could a documentation fix be requested to highlight it as a pitfall in the 
style guide and the language overview?  Warnings about this would also be 
helpful, in the absence of a proper fix.

----------------------------------------
Bug #9848: Variable interpolation in class parameters seems random
https://projects.puppetlabs.com/issues/9848#change-60614

Author: Carlos Sanchez
Status: Accepted
Priority: Normal
Assignee: 
Category: parameterized classes
Target version: Telly
Affected Puppet version: 2.7.1
Keywords: parameter variable class interpolation evaluation
Branch: 


In class parameters, things like x="x", y="y${x}" don't always evaluate right 
(y="yx"), seems random. I'm using 2.7.1

<pre>
class test1(
    $servicex = "sonar",
    $logfoldera = "${homex}/logs",
    $logfoldere = "${homey}/logs",
    $logfolderh = "${homez}/logs",
    $logfolder = "${homex}/logs",
    $homex = "/var/${servicex}",
    $homey = "/var/${servicex}",
    $homez = "/var/${servicex}") {

    notice($homex)
    notice($homey)
    notice($homez)
    notice("-----")
    notice($logfoldera)
    notice($logfoldere)
    notice($logfolderh)
}
</pre>

output :

<pre>
notice: Scope(Class[Test1]): /var/sonar
notice: Scope(Class[Test1]): /var/sonar
notice: Scope(Class[Test1]): /var/sonar
notice: Scope(Class[Test1]): -----
notice: Scope(Class[Test1]): /var/sonar/logs
notice: Scope(Class[Test1]): /logs
notice: Scope(Class[Test1]): /logs
</pre>


Note the last two messages should print "/var/sonar/logs"
Ordering the paramenters in the order they are needed gets the same result.

Just by changing the name of the parameters from class test1 to test2 I get 
different evaluations of the variables, one is right and two are wrong, you can 
see that in [this gist](https://gist.github.com/1250837)

Commented on [the user 
list](https://groups.google.com/d/topic/puppet-users/x_BCxE6SQcM/discussion)



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to