diff options
-rw-r--r-- | lib/chef/node_map.rb | 16 | ||||
-rw-r--r-- | lib/chef/provider/group/suse.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/group/usermod.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/ifconfig/debian.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/package.rb | 6 |
5 files changed, 20 insertions, 26 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index bfa884d6d7..fd284683bd 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -132,10 +132,24 @@ class Chef whitelist.empty? || whitelist.any? { |v| v == :all || v == value } end + def matches_version_list?(node, filters, attribute) + # It's super common for the filter to be nil. Catch that so we don't + # spend any time here. + return true if !filters[attribute] + filter_values = Array(filters[attribute]) + value = node[attribute] + + filter_values.empty? || + Array(filter_values).any? do |v| + Chef::VersionConstraint::Platform.new(v).include?(value) + end + end + def filters_match?(node, filters) matches_black_white_list?(node, filters, :os) && matches_black_white_list?(node, filters, :platform_family) && - matches_black_white_list?(node, filters, :platform) + matches_black_white_list?(node, filters, :platform) && + matches_version_list?(node, filters, :platform_version) end def block_matches?(node, block) diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb index 3831b555e6..97acafb2a1 100644 --- a/lib/chef/provider/group/suse.rb +++ b/lib/chef/provider/group/suse.rb @@ -23,11 +23,7 @@ class Chef class Group class Suse < Chef::Provider::Group::Groupadd provides :group, platform: %w(opensuse) - provides :group, platform: %w(suse) do |node| - if node[:platform_version] - Chef::VersionConstraint::Platform.new('< 12.0').include?(node[:platform_version]) - end - end + provides :group, platform: %w(suse), platform_version: '< 12.0' def load_current_resource super diff --git a/lib/chef/provider/group/usermod.rb b/lib/chef/provider/group/usermod.rb index 465592af28..d7f302c19b 100644 --- a/lib/chef/provider/group/usermod.rb +++ b/lib/chef/provider/group/usermod.rb @@ -24,11 +24,7 @@ class Chef class Usermod < Chef::Provider::Group::Groupadd provides :group, os: "openbsd" - provides :group, platform: %w(opensuse) do |node| - if node[:platform_version] - Chef::VersionConstraint::Platform.new('>= 12.3').include?(node[:platform_version]) - end - end + provides :group, platform: %w(opensuse), platform_version: '>= 12.3' provides :group, platform: %w(openindiana opensolaris nexentacore omnios solaris2 smartos hpux) def load_current_resource diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb index 03aeae9a93..1e6863c8b5 100644 --- a/lib/chef/provider/ifconfig/debian.rb +++ b/lib/chef/provider/ifconfig/debian.rb @@ -23,16 +23,8 @@ class Chef class Provider class Ifconfig class Debian < Chef::Provider::Ifconfig - provides :ifconfig, platform: %w(ubuntu) do |node| - if node[:platform_version] - Chef::VersionConstraint::Platform.new('>= 11.10').include?(node[:platform_version]) - end - end - provides :ifconfig, platform: %w(debian) do |node| - if node[:platform_version] - Chef::VersionConstraint::Platform.new('>= 7.0').include?(node[:platform_version]) - end - end + provides :ifconfig, platform: %w(ubuntu), platform_version: '>= 11.10' + provides :ifconfig, platform: %w(debian), platform_version: '>= 7.0' INTERFACES_FILE = "/etc/network/interfaces" INTERFACES_DOT_D_DIR = "/etc/network/interfaces.d" diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index fbf8a5ce31..469172f870 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -517,11 +517,7 @@ class Chef Chef.set_provider_priority_array :package, Pacman, platform: %w(arch) Chef.set_provider_priority_array :package, Ips, platform: %w(openindiana opensolaris omnios solaris2) Chef.set_provider_priority_array :package, Solaris, platform: %w(nexentacore) - Chef.set_provider_priority_array :package, Solaris, platform: %w(solaris2) do |node| - if node[:platform_version] - Chef::VersionConstraint::Platform.new('< 5.11').include?(node[:platform_version]) - end - end + Chef.set_provider_priority_array :package, Solaris, platform: %w(solaris2), platform_version: '< 5.11' Chef.set_provider_priority_array :package, SmartOS, platform: %w(smartos) Chef.set_provider_priority_array :package, Aix, platform: %w(aix) |