saltstack/salt — pull request #6294 by kfdm (2013-07-24 04:22:53+00:00)
Title: Add append, remove, and delval to the grains module

I wrote a similar module for internal use, but thought it might be useful for others. Pushing a draft to get some comments.

The basic usage is for matching from a list of items. For example.

```
# On the minion
salt-call grains.setval roles webserver
salt-call grains.setval roles databaseserver

# On the master
salt -G 'roles:webserver' test.ping

# in a top file
base:
'roles:webserver':
- match: grain
- nginx
- php
'roles:databaseserver':
- match: grain
- mysql-server
```

The main questions I have are around the code in setval(). It seems like the code interacting with reading the grains file, should possibly be put in its own function, to allow for simpler usage from elsewhere. Would it be cleaner to set it as a private function in the grains module (_get ?) or in more of a utility module (salt.util.grains ?)