[英]Puppet getvar() function not working
I am looking at https://github.com/puppetlabs/puppetlabs-stdlib#getvar 我在看https://github.com/puppetlabs/puppetlabs-stdlib#getvar
My manifests 我的清单
class test::var inherits stdlib {
$datalocation = 'site::data'
$bar = getvar("${datalocation}::bar")
# Equivalent to $bar = $site::data::bar
notify{"This is getvar() testing variable, Now bar equal to ${bar}":}
}
when i run puppet on client i get blank 当我在客户端上运行p时,我变得空白
[root@401 ~]# puppet agent --test --noop
...
...
Notice: /Stage[main]/test::Var/Notify[This is getvar() testing variable, Now bar equal to '']/message: current_value absent, should be This is getvar() testing variable, Now bar equal to '' (noop)
Am i missing something? 我想念什么吗?
When I run the above code, part of my puppet output is the following warning: 当我运行上面的代码时,我的人偶输出的一部分是以下警告:
Warning: Scope(Class[Test::Var]): Could not look up qualified variable 'site::data::bar'; class site::data could not be found
What this is saying is that site::data::bar
doesn't exist in the current scope. 这是说site::data::bar
在当前范围中不存在。 If you define it first, then your assignment and following notification will work as expected. 如果先定义,则您的分配和后续通知将按预期工作。
class site::data {
$bar = 'foo'
}
class test::var inherits stdlib {
require site::data
$datalocation = 'site::data'
$bar = getvar("${datalocation}::bar")
# Equivalent to $bar = $site::data::bar
notify{"This is getvar() testing variable, Now bar equal to ${bar}":}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.