傀儡标准库“成员”功能不工作
puppet stdlib 'member" function not working
正在尝试使用 puppet stdlib 模块的成员函数:
有效:
$myvariable = 'FOO'
那么在使用成员函数时:
member(['FOO','BAR'], $myvariable)
我不断收到错误消息:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Function 'member' must be the value of a statement at /etc/puppet/modules/mymodule/manifests/init.pp:###
查看 member 的 stdlib 文档,我们发现 member 是一个右值。这意味着在这种情况下,您需要分配其输出。这就是 must be the value of a statement
的错误消息所暗示的。请注意有关 l 值和 r 值的有用维基百科文章 https://en.wikipedia.org/wiki/Value_(computer_science)#lrvalue。
您的代码将起作用,例如,如果您将 member(['FOO','BAR'], $myvariable)
的输出分配给变量或资源属性。
例如:
$myvariable = 'FOO'
$variable = member(['FOO','BAR'], $myvariable)
notify { $variable: }
将在编译期间导致通知 'true'。
正在尝试使用 puppet stdlib 模块的成员函数:
有效:
$myvariable = 'FOO'
那么在使用成员函数时:
member(['FOO','BAR'], $myvariable)
我不断收到错误消息:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Function 'member' must be the value of a statement at /etc/puppet/modules/mymodule/manifests/init.pp:###
查看 member 的 stdlib 文档,我们发现 member 是一个右值。这意味着在这种情况下,您需要分配其输出。这就是 must be the value of a statement
的错误消息所暗示的。请注意有关 l 值和 r 值的有用维基百科文章 https://en.wikipedia.org/wiki/Value_(computer_science)#lrvalue。
您的代码将起作用,例如,如果您将 member(['FOO','BAR'], $myvariable)
的输出分配给变量或资源属性。
例如:
$myvariable = 'FOO'
$variable = member(['FOO','BAR'], $myvariable)
notify { $variable: }
将在编译期间导致通知 'true'。