Issue #2309 has been updated by Ohad Levy.
Status changed from Rejected to Re-opened
The contennt of the template is:
<pre>
<%= scope.lookupvar("a::dirs") %>
</pre>
I've also tried your solution before, which doesn't work as well.
I think that the main problem is here: (which got me to the conclusion that the
order is wrong)
running with template - you can see that the template is processed first.
<pre>
puppet -d test.pp
debug: Scope(Class[b]): Retrieving template /tmp/dirs.erb
debug: template[/tmp/dirs.erb]: Bound template variables for /tmp/dirs.erb in
0.00 seconds
debug: template[/tmp/dirs.erb]: Interpolated template /tmp/dirs.erb in 0.00
seconds
debug: Defining before on Dir[/tmp]
debug: Defining before on Dir[/tmp/a]
debug: Defining before on Dir[/tmp/b]
debug: Creating default schedules
debug: Finishing transaction 69822889213800 with 0 changes
debug: //Node[default]/a/Dir[/tmp/a]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/File[/tmp/b]/before: requires
File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/a]/File[/tmp/a]/before: requires
File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp]/File[/tmp]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/File[/tmp/b]: Autorequiring File[/tmp]
debug: //Node[default]/a/Dir[/tmp/a]/File[/tmp/a]: Autorequiring File[/tmp]
debug: //Node[default]/b/File[/tmp/dirs]/checksum: Initializing checksum hash
debug: //Node[default]/b/File[/tmp/dirs]: Creating checksum
{md5}68b329da9893e34099c7d8ad5cb9c940
debug: Finishing transaction 69822890682820 with 0 changes
</pre>
running with no template
<pre>
puppet -d test.pp
debug: Defining before on Dir[/tmp/b]
debug: Defining before on Dir[/tmp/a]
debug: Defining before on Dir[/tmp]
debug: Creating default schedules
debug: Finishing transaction 70189412780520 with 0 changes
debug: //Node[default]/a/Dir[/tmp/a]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/File[/tmp/b]/before: requires
File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/a]/File[/tmp/a]/before: requires
File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp]/File[/tmp]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/before: requires File[/tmp/dirs]
debug: //Node[default]/a/Dir[/tmp/b]/File[/tmp/b]: Autorequiring File[/tmp]
debug: //Node[default]/a/Dir[/tmp/a]/File[/tmp/a]: Autorequiring File[/tmp]
debug: //Node[default]/b/File[/tmp/dirs]/checksum: Initializing checksum hash
debug: //Node[default]/b/File[/tmp/dirs]: Creating checksum
{md5}68b329da9893e34099c7d8ad5cb9c940
debug: //Node[default]/b/File[/tmp/dirs]: Changing content
debug: //Node[default]/b/File[/tmp/dirs]: 1 change(s)
notice: //Node[default]/b/File[/tmp/dirs]: Filebucketed to with sum
68b329da9893e34099c7d8ad5cb9c940
debug: //Node[default]/b/File[/tmp/dirs]/checksum: Replacing /tmp/dirs checksum
{md5}68b329da9893e34099c7d8ad5cb9c940 with {md5}dd50ac53127aa2f3578835acc1415712
notice: //Node[default]/b/File[/tmp/dirs]/content: content changed
'{md5}68b329da9893e34099c7d8ad5cb9c940' to
'{md5}dd50ac53127aa2f3578835acc1415712'
debug: Finishing transaction 70189414240760 with 1 changes
</pre>
another observation:
when changing the variable from a string to array (e.g. $dirs = [""] instead of
$dirs = "") nothing works at all.
----------------------------------------
Bug #2309: templates are processed too early in the compliation
http://projects.reductivelabs.com/issues/2309
Author: Ohad Levy
Status: Re-opened
Priority: Normal
Assigned to:
Category:
Target version:
Complexity: Unknown
Affected version: 0.24.8
Keywords:
it seems that templates ignore variable scopes, consider this code:
<pre>
node default {
include a
include b
}
class a {
$dirs = ""
dir{["/tmp","/tmp/a","/tmp/b"]: before => File["/tmp/dirs"]}
}
class b {
file{"/tmp/dirs": content => $a::dirs}
#file{"/tmp/dirs": content => template("/tmp/dirs.erb")}
}
define dir() {
$a::dirs += " $name"
file {$name: ensure => directory }
}
</pre>
using template the output of the file is "", but when dumping the variable
directly, the content is correct.
--
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://reductivelabs.com/redmine/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
-~----------~----~----~----~------~----~------~--~---