7a192d7bea
- fix spec tests to include osfamily fact - add spec tests to verify current default behavior unimpacted. - manage the update-stamp file in puppet via content rather than a served file. - update custom fact to return -1 if the file doesn't exist - add spec test for custom fact - refactor to use a variable vs a collector/override - document parameters a bit more verbosely - remove empty unconstrained fact - Add osfamily fact to backports tests to facilitate functional tests on non-debian hosts
18 Zeilen
597 B
Ruby
18 Zeilen
597 B
Ruby
require 'facter'
|
|
|
|
#This is derived from the file /var/lib/apt/periodic/update-success-stamp
|
|
# This is generated upon a successful apt-get update run natively in ubuntu.
|
|
# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes
|
|
Facter.add('apt_update_last_success') do
|
|
confine :osfamily => 'Debian'
|
|
setcode do
|
|
if File.exists?('/var/lib/apt/periodic/update-success-stamp')
|
|
#get epoch time
|
|
lastsuccess = File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i
|
|
lastsuccess
|
|
else
|
|
lastsuccess = -1
|
|
lastsuccess
|
|
end
|
|
end
|
|
end
|