saltstack/salt — pull request #6555 by flupke (2013-08-07 21:15:27+00:00)
Title: Add support for order clauses in pillar top files

When a minion matches multiple targets in the pillar top file (for example by its nodegroup and its hostname), all the state files of the targets are merged.

This is problematic when you want to override pillars for a specific minion, but still keep defaults for the rest of the group. For example say you define a `ssh_vars` pillar for a nodegroup and a host:

top.sls:
```yaml
base:
all_servers:
- match: nodegroup
- ssh
backup.domain.com:
- ssh.backup
```

ssh/init.sls:
```yaml
ssh_vars:
allowed:
- bill
- john
```

ssh/backup.sls:
```yaml
ssh_vars:
allowed:
- bill
```

If `backup.domain.com` is part of the `all_servers` nodegroup, both the `ssh` and `ssh.backup` state files will be merged, and only one `ssh_vars` pillar value will survive, but you don't know which since the merge order is random.

This pull request adds support for defining merge order explicitly:

top.sls
```yaml
base:
all_servers:
- match: nodegroup
- order: 1
- ssh
backup.domain.com:
- order: 2
- ssh.backup
```

Here `ssh.backup` will be merged after `ssh`, and you're sure that the `ssh_vars` pillar for `backup.domain.com` will come from `ssh.backup`.