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.

1 Answer 1

2

You can write a Facter to check if the file exists :

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

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

Then in your manifests, call the fact,

if ($::reboot_required == 'true') {
    notify {"Reboot Required":}
}
Sign up to request clarification or add additional context in comments.

3 Comments

Actually it is not working for me... it is always echoing "Reboot Required, even when the file is not there. What could be happening?
see my edit. I have added true to the if condition. That might fix it.
That is it! Thanks! :-) Just learned that puppet facts are always strings, that is so bad..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.