当我使用 puppet 2.7.22 运行以下 puppet 清单时:
Exec {
logoutput => true,
path => '/bin',
}
define c {
exec {"echo [two]: ${b::x}": }
}
class a {
exec {"echo [one]: ${b::x}": }
include b
}
class b { $x = "asdf" }
c {'two': }
class {'a': }
我收到以下输出:
$ puppet apply test.pp
warning: Scope(Class[A]): Could not look up qualified variable 'b::x'; class b has not been evaluated at /tmp/l/a.pp:11
warning: Scope(Class[A]): Could not look up qualified variable 'b::x'; class b has not been evaluated at /tmp/l/a.pp:11
notice: /Stage[main]//C[two]/Exec[echo [two]: asdf]/returns: [two]: asdf
notice: /Stage[main]//C[two]/Exec[echo [two]: asdf]/returns: executed successfully
notice: /Stage[main]/A/Exec[echo [one]: ]/returns: [one]:
notice: /Stage[main]/A/Exec[echo [one]: ]/returns: executed successfully
notice: Finished catalog run in 0.15 seconds
现在我知道木偶按解析顺序评估变量。我知道在使用 b 的 x 变量的 exec 之后包含class b
from是愚蠢的。我不明白的是,为什么定义(名称为'two'的实例)中的exec具有一个评估版本,即使它在解析顺序方面出现在类'a'之前。class a
type c
$b::x
唯一可以解释这一点的是,如果定义的类型在解析时被延迟了?如果是这种情况,puppetlabs 是否有任何关于此(或任何地方)的文档和/或源的哪一部分将标准与定义的类型资源区分开来?(我试过找到它compiler.rb
但失败了)。