0
我想要执行一些类只有当特定的rpm版本不存在。根据条件在傀儡执行类
例如:
class base{
if specified_rpm_absent {
include base::class1
include base::class2
}
else {
notify {"Already there":}
}
}
我想要执行一些类只有当特定的rpm版本不存在。根据条件在傀儡执行类
例如:
class base{
if specified_rpm_absent {
include base::class1
include base::class2
}
else {
notify {"Already there":}
}
}
你可以做的是定义一个custom fact返回true或false取决于这个RPM的存在或不存在,然后在条件逻辑使用它,即
事实上代码:
Facter.add(:specified_rpm_absent) do
setcode do
# Some Ruby code to return true or false depending on RPM package
# Facter::Core::Execution.exec() can be used to execute a shell
# command.
end
end
木偶4
class base {
if $facts['specified_rpm_absent'] {
include base::class1
include base::class2
}
else {
notify {"Already there":}
}
}
木偶3
class base {
if $::specified_rpm_absent {
include base::class1
include base::class2
}
else {
notify {"Already there":}
}
}
的OP辩称以下,最好是在这里使用的傀儡功能,并且功能也让争论。
但是,如果使用Masterless Puppet,但不受Puppet支持,函数可用于此目的,此用例在Jussi Heinonen的“学习木偶”(2015)中描述。
我不会推荐这种方法的几个原因:
最后,应该指出的是,根据是否安装RPM来做出决定的设计可能存在更根本性的错误。为什么傀儡不知道RPM是否已安装?
任何其他不需要自定义事实的解决方案? –
如果您的要求是仅在特定rpm版本不存在的情况下执行类,那么通常使用自定义事实来实现。我想不出还有其他办法可以做到。 –
谢谢。需要了解自定义事实! –