From 6786d506e373c08df8ad0b00c5a9d7275ba0ed1a Mon Sep 17 00:00:00 2001 From: gimmy Date: Fri, 13 Mar 2020 14:09:41 +0200 Subject: [PATCH] (maint) Update apt custom facts This commit updates apt custom facts because the evaluation of custom facts code has changed between facter 2 and facter 4. In facter 2, when a custom fact is loaded, the code in `add` block was not executed. In facter 4, when a custom fact is loaded, the code outside `setcode` block is executed(same as Facter 3). --- lib/facter/apt_updates.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index c2f38a8..eae1cf3 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -26,23 +26,27 @@ def get_updates(upgrade_option) end end end - - setcode do - if !apt_updates.nil? && apt_updates.length == 2 - apt_updates != [[], []] - end - end apt_updates end Facter.add('apt_has_updates') do confine osfamily: 'Debian' - apt_package_updates = get_updates('upgrade') + setcode do + apt_package_updates = get_updates('upgrade') + if !apt_package_updates.nil? && apt_package_updates.length == 2 + apt_package_updates != [[], []] + end + end end Facter.add('apt_has_dist_updates') do confine osfamily: 'Debian' - apt_dist_updates = get_updates('dist-upgrade') + setcode do + apt_dist_updates = get_updates('dist-upgrade') + if !apt_dist_updates.nil? && apt_dist_updates.length == 2 + apt_dist_updates != [[], []] + end + end end Facter.add('apt_package_updates') do -- 2.32.3