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版本不存在的情況下執行類,那麼通常使用自定義事實來實現。我想不出還有其他辦法可以做到。 –
謝謝。需要了解自定義事實! –