Issue #12577 has been updated by Chris Price.
File 12577.pp added
Status changed from Investigating to Accepted
Assignee deleted (Chris Price)
This is reproducible in both 2.6.2 and master. It appears that the scope in
which a variable is resolved may be different when it is evaluated inside of
quotes as opposed to outside of them; my guess is that variables inside of
quotes are evaluated and interpolated at parse time, whereas variables outside
of quotes are evaluated somewhere later on in the life cycle of the catalog /
resource application.
In this particular example, that means that the quoted "$foo" gets evaluated
prior to the "bar" resource evaluation.
Attached a manifest for easy repro; here's a sample run:
<pre>
$ puppet apply --verbose ./12577.pp
info: Applying configuration version '1329850062'
notice: /Stage[main]/Foo/File[/tmp/12577/unquotedbam]/ensure: defined content
as '{md5}acbd18db4cc2f85cedef654fccc4a4d8'
notice: /Stage[main]/Foo/File[/tmp/12577/unquotedfoo]/ensure: defined content
as '{md5}14758f1afd44c09b7992073ccf00b43d'
notice: /Stage[main]/Foo/File[/tmp/12577/quotedfoo]/ensure: defined content as
'{md5}d3b07384d113edec49eaa6238ad5ff00'
notice: /Stage[main]/Foo/File[/tmp/12577/quotedbaz]/ensure: defined content as
'{md5}d3b07384d113edec49eaa6238ad5ff00'
notice: /Stage[main]/Foo/File[/tmp/12577/quotedbam]/ensure: defined content as
'{md5}d3b07384d113edec49eaa6238ad5ff00'
notice: /Stage[main]/Foo/File[/tmp/12577/unquotedbaz]/ensure: defined content
as '{md5}14758f1afd44c09b7992073ccf00b43d'
$ cat quotedfoo unquotedfoo quotedbaz unquotedbaz quotedbam unquotedbam
foo
foobar
foo
foobar
foo
foo
</pre>
----------------------------------------
Bug #12577: Append operator in defines
https://projects.puppetlabs.com/issues/12577#change-55365
Author: Roland Kaminski
Status: Accepted
Priority: Normal
Assignee:
Category: language
Target version:
Affected Puppet version: 2.6.2
Keywords: append scope define
Branch:
Hi,
recently we were trying to assemble a file made of different parts. We stumbled
upon, in my opinion, strange behavior of the append operator. The example below
produces two different files with different content. From what I gather from
the language guide both files should contain the string "foo" but the second
file does not. We are using the debian-squeeze version of the puppet client and
master (I do not have a newer version at hand to test whether this has already
been addressed.
Note that exchanging the define with a class and then including class bar would
result in two files with the string "foobar". The language guide is unclear
about such cases too.
<pre>
class foo {
$foo = "foo"
define bar () {
$foo::foo += "bar"
}
bar { "bar": }
file {
"/root/foo":
content => "$foo";
"/root/foobar":
content => $foo;
}
}
</pre>
--
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.