![Puppet - 自定义函数 - 语句 - 错误 - “必须是语句的值......”](https://linux22.com/image/668017/Puppet%20-%20%E8%87%AA%E5%AE%9A%E4%B9%89%E5%87%BD%E6%95%B0%20-%20%E8%AF%AD%E5%8F%A5%20-%20%E9%94%99%E8%AF%AF%20-%20%E2%80%9C%E5%BF%85%E9%A1%BB%E6%98%AF%E8%AF%AD%E5%8F%A5%E7%9A%84%E5%80%BC......%E2%80%9D.png)
看起来很简单...
# /path/to/puppet/modules/custom/lib/puppet/parser/functions
module Puppet::Parser::Functions
newfunction(:release_check) do |args|
raise(Puppet::ParseError, "Testing!")
end
end
# /path/to/puppet/modules/mysql/manifests/install.pp
class mysql::install {
# Doesn't work
release_check(1)
# Does work, but I don't want anything returned making the assignment superfluous
$whocares = release_check(1)
}
但我一直收到这个错误:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Function 'release_check' must be the value of a statement at /etc/puppet/modules/mysql/manifests/install.pp:4 on node service-a-3
但根据木偶文档,我应该能够按照书面说明拨打电话。
这个简单的 write_line_to_file 函数是语句函数的一个示例。它执行操作,但不返回值。
我错过了什么?
CentOS:6.7 Puppetmaster:2.7.26
答案1
经过一番苦苦思索之后,似乎你必须在对自定义函数进行每次更改后重新启动 puppetmaster,尽管每次更改后都会将更改发送给代理。
误导至少可以说。