CS-Dave
CS-Dave

Reputation: 73

Minion not picking up multiple pillar sources

I have a problem where a minion isn't picking up both sources of pillar information, but instead only picking up to the last source referred to. For an example the following is my /srv/pillar/top.sls:

base:
  'client.id':
    - users.support
    - users.dev

The content of my /srv/pillar/users/support.sls is as follows:

users:
  - name: supportname
    fullname: Name of Support user
    uid: 1001
    groups:
      - sudo
      - support

The content of my /srv/pillar/users/dev.sls is as follows:

users:
  - name: devname
    fullname: Name of Dev user
    uid: 1002
    groups:
      - dev

When calling salt 'client.id' pillar.items it will only show the last specified pillar (for this example, only dev information would be shown). If I was to switch the order the opposite content is shown. I'm really stumped as to what could be causing this.

Any help would be very much appreciated.

Many thanks,

David

Upvotes: 1

Views: 427

Answers (1)

Christophe Drevet
Christophe Drevet

Reputation: 945

Currently, SaltStack has a limited merging strategy for pillars [1]. In your case, the users key is defined as a list. Lists can't be merged in pillars, so the last parsed pillar wins. That's what you see.

However, dicts are merged, provided the keys are different. You may use this for your need:

/srv/pillar/users/support.sls:

users:
  supportname:
    fullname: Name of Support user
    uid: 1001
    groups:
      - sudo
      - support

/srv/pillar/users/dev.sls:

users:
  devname:
    fullname: Name of Dev user
    uid: 1002
    groups:
      - dev

You'll end with a users dictionary containing two entries: supportname and devname. You can then loop on it with for username, userdef in salt['pillar.get']('users', {}).iteritems(), for example.

[1] https://docs.saltstack.com/en/latest/topics/pillar/#pillar-namespace-merges

Upvotes: 1

Related Questions