summaryrefslogtreecommitdiff
path: root/lib/chef/node_map.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r--lib/chef/node_map.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index dd118c26cf..3c78d6cb9b 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -219,6 +219,11 @@ class Chef
private
+ def platform_family_query_helper?(node, m)
+ method = "#{m}?".to_sym
+ ChefUtils::DSL::PlatformFamily.respond_to?(method) && ChefUtils::DSL::PlatformFamily.send(method, node)
+ end
+
#
# Succeeds if:
# - no negative matches (!value)
@@ -235,11 +240,19 @@ class Chef
# Split the blacklist and whitelist
blacklist, whitelist = filter_values.partition { |v| v.is_a?(String) && v.start_with?("!") }
- # If any blacklist value matches, we don't match
- return false if blacklist.any? { |v| v[1..-1] == value }
+ if attribute == :platform_family
+ # If any blacklist value matches, we don't match
+ return false if blacklist.any? { |v| v[1..-1] == value || platform_family_query_helper?(node, v[1..-1]) }
- # If the whitelist is empty, or anything matches, we match.
- whitelist.empty? || whitelist.any? { |v| v == :all || v == value }
+ # If the whitelist is empty, or anything matches, we match.
+ whitelist.empty? || whitelist.any? { |v| v == :all || v == value || platform_family_query_helper?(node, v) }
+ else
+ # If any blacklist value matches, we don't match
+ return false if blacklist.any? { |v| v[1..-1] == value }
+
+ # If the whitelist is empty, or anything matches, we match.
+ whitelist.empty? || whitelist.any? { |v| v == :all || v == value }
+ end
end
def matches_version_list?(node, filters, attribute)