saltstack/salt — pull request #1299 by tvaughan (2012-05-18 14:24:45+00:00)
Title: Copy grain matcher to create pillar matcher.

First, please see the pillars documentation:
http://salt.readthedocs.org/en/latest/topics/pillar/index.html. Next,
perhaps an example will explain this best...

Let's say you have a `/src/pillar/top.sls` that looks like:

base:
'hostname1':
- production
'hostname2':
- development

And a `/srv/pillar/production.sls` that looks like:

role: production
countrycode: us

And a `/srv/pillar/development.sls` that looks like:

role: development
countrycode: cl

This means that `/srv/salt/top.sls` could now look like:

base:
'*':
- ssh
'role:production':
- match: pillar
- users.production
- default
- clojure
'role:development':
- match: pillar
- users.development
- default.dev
- clojure.dev

Both `role` and `countrycode` may also be used as a template variable
as explained in the pillar documentation above.

For a real-world example, please see:

* https://github.com/rentalita/ubuntu-setup
* https://github.com/rentalita/ubuntu-setup/blob/master/salt/apt/init.sls.
* https://github.com/rentalita/ubuntu-setup/blob/master/salt/apt/sources.list

This commit also extends the salt command-line client so that it too
may use the pillar matcher, like:

salt -I 'role:production' test.ping

Documentation and tests are not included in this commit. These will
come in a later commit.

The `pillar_match` routine is simply a copy of the `grain_match`
routine. But I grep'd for the `exsel` matcher to figure out what parts
of the code needed to be touched in order to (hopefully) make this
work. I suppose a pillar pcre matcher could be made just as easily.