From eb9305f9088f645cab52bc73b28e84bc148e54ac Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Wed, 14 Aug 2024 11:41:21 -0700 Subject: [PATCH] Set default last run times --- lib/facter/munki_last_run.rb | 5 ++--- lib/facter/munki_last_run_unix.rb | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/facter/munki_last_run.rb b/lib/facter/munki_last_run.rb index 8519822..f747f43 100644 --- a/lib/facter/munki_last_run.rb +++ b/lib/facter/munki_last_run.rb @@ -6,13 +6,12 @@ Facter.add(:munki_last_run) do confine kernel: "Darwin" setcode do + last_run = "never" if File.exist?(report_plist) require "puppet/util/plist" if Puppet.features.cfpropertylist? plist = Puppet::Util::Plist.read_plist_file(report_plist) last_run = plist["StartTime"] - last_run - else - "never" end + last_run end end diff --git a/lib/facter/munki_last_run_unix.rb b/lib/facter/munki_last_run_unix.rb index 6d682e4..3e7d680 100644 --- a/lib/facter/munki_last_run_unix.rb +++ b/lib/facter/munki_last_run_unix.rb @@ -5,11 +5,13 @@ Facter.add(:munki_last_run_unix) do confine kernel: "Darwin" setcode do + last_run = 0 munki_last_run = Facter.value(:munki_last_run) if munki_last_run == "never" - 0 + last_run = 0 else - Time.parse(munki_last_run).to_i + last_run = Time.parse(munki_last_run).to_i end + last_run end end