From: gimmy Date: Fri, 13 Mar 2020 12:09:41 +0000 (+0200) Subject: (maint) Update apt custom facts X-Git-Tag: v7.4.2~4^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6786d506e373c08df8ad0b00c5a9d7275ba0ed1a;p=puppet-modules%2Fpuppetlabs-apt.git (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). --- 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