0

For example, if I want print "Reboot required!" when the file /var/run/reboot-required exists, how could I declare this in puppet?

I learned about alert(), warning() and the notify type, but I don't know how to trigger they only when some file exists.

4

1 回答 1

2

您可以编写一个 Factor 来检查文件是否存在:

/etc/puppet/modules/mymodulename/lib/facter/reboot_require.rb

Facter.add("reboot_required") do
        setcode do
                File.exist?("/var/run/reboot-required")
        end
end

然后在你的清单中,调用事实,

if ($::reboot_required == 'true') {
    notify {"Reboot Required":}
}
于 2013-05-29T20:12:32.440 回答