about dynamic lookup from an included puppet file:
puppet 2.7 warns about it, and puppet 3.2 stops working, as expected.
however,
about dynamic lookup from a template called on an included puppet file:
both puppet 2.7 and puppet 3.2 it works, without even a warning. (see in red the below example)
Why is that?
And so, does this mean that dynamic lookup is bad from a puppet file, but not from a template file?
See below a specific example:
test.pp
class c1 {
$var = 'hello'
notify {"var from c1: $var": }
include c2
}
class c2 {
notify {"var from c2: $var": }
file { '/tmp/file.txt':
content => template('file.txt.erb'),
}
}
class { c1: }
file.txt.erb
var from file.txt.erb: <%= @var %>
----
running with puppet 2.7.19:
$ puppet apply --templatedir templates/ test.pp
notice: var from c1: hello
notice: /Stage[main]/C1/Notify[var from c1: hello]/message: defined 'message' as 'var from c1: hello'
notice: /Stage[main]/C2/File[/tmp/file.txt]/ensure: defined content as '{md5}ea0d73f3957b0893f63e03cb9d8c9d98'
notice: var from c2: hello
notice: /Stage[main]/C2/Notify[var from c2: hello]/message: defined 'message' as 'var from c2: hello'
notice: Finished catalog run in 0.05 seconds
$ cat /tmp/file.txt
var from file.txt.erb: hello
running with puppet 3.3.2:
$ puppet apply --templatedir templates/ test.pp
Notice: Compiled catalog for mac4c.local in environment production in 0.16 seconds
Notice: var from c1: hello
Notice: /Stage[main]/C1/Notify[var from c1: hello]/message: defined 'message' as 'var from c1: hello'
Notice: var from c2:
Notice: /Stage[main]/C2/Notify[var from c2: ]/message: defined 'message' as 'var from c2: '
Notice: /Stage[main]/C2/File[/tmp/file.txt]/ensure: defined content as '{md5}ea0d73f3957b0893f63e03cb9d8c9d98'
$ cat /tmp/file.txt
var from file.txt.erb: hello