木偶模块资源属性

有没有办法在puppet模块中打印属性的值? 例如,如果您有一个文件资源:

file {'myfile': path => '/this/is/my/path', ensure => present, owner => 'someuser', group => 'somegroup' } 

你能打印“path”属性的值吗? 也许使用通知?

 notify {"the value of path is: " __________} 

如果您将您的属性作为string传递,则不行。

但是,如果将其分配给variables,则可以重新使用该属性。 例:

 $file_path = '/this/is/my/path' file { 'myfile': path => $file_path, ensure => present, owner => 'someuser', group => 'somegroup' } notify { "the value of path is: ${file_path}": } 

注意分隔资源名称和参数的最后的冒号(在这种情况下没有,所以资源只是终止)。 上面的notify也可以写成这个( 参考 ):

 notify { 'my_notify': message => "the value of path is: ${file_path}", } 

另外,请注意正确使用单引号和双引号。 根据Puppet Lint, 双引号只能在string包含一个插值variables时使用 ,而这些variables应该被括在花括号中 。