Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy grain matcher to create pillar matcher. #1299

Merged
merged 1 commit into from May 18, 2012
Merged

Copy grain matcher to create pillar matcher. #1299

merged 1 commit into from May 18, 2012

Conversation

tvaughan
Copy link

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:

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.

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.
@thatch45
Copy link
Member

This looks great Tom! It is in, keep up the awesomeness!

thatch45 added a commit that referenced this pull request May 18, 2012
Copy grain matcher to create pillar matcher.
@thatch45 thatch45 merged commit 264d5fa into saltstack:develop May 18, 2012
@tvaughan
Copy link
Author

Ha! I'm flattered. The pleasure is mine.

@thatch45
Copy link
Member

Matchers are a core part of the Salt system, and having more in here helps a great deal. That and you have been on fire!

@tvaughan
Copy link
Author

Sorry that I didn't provide the docs and tests like I said I would. Looks like @thatch45 added these in later commits. Is there anything left that needs to be added that I could do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants