Permalink
Browse files

Add support for matching grains that are in a list

Fixes #752, Before this matching grains in a list was difficult at
best. Now matching will match any individual member of a list. This
makes adding a roles grain much easier!
  • Loading branch information...
1 parent c9aa48a commit b72fa96756582efc11c3a1f117999afd60a215c7 @thatch45 thatch45 committed Feb 25, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 salt/minion.py
View
@@ -599,6 +599,12 @@ def grain_match(self, tgt):
if comps[0] not in self.opts['grains']:
log.error('Got unknown grain from master: {0}'.format(comps[0]))
return False
+ if isinstance(self.opts['grains'][comps[0], list):
+ # We are matching a single component to a single list member
+ for member in self.opts['grains'][comps[0]:
+ if re.match(comps[1], str(self.opts['grains'][comps[0]])):
+ return True
+ return False
return bool(re.match(comps[1], str(self.opts['grains'][comps[0]])))
def exsel_match(self, tgt):

0 comments on commit b72fa96

Please sign in to comment.