saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.13k stars 5.47k forks source link

Pillars only work in Master Branch when using gitfs (v2014.1.10) #16341

Closed naegelin closed 10 years ago

naegelin commented 10 years ago

In a recent test it came about that Pillars only work if defined in the Master Branch when using gitfs. I've tried this over and over and it always seems to hold true.

Example:

The following top.sls PILLAR file will fail (no pillars created) if pushed to the "test" branch where as the STATE file will behave as expected (testpillar will apply to host names starting with word test). The Base definition for the top.sls pillar in the master branch works.

contents of /salt/pillar/top.sls:

test:
  'test*':
    - testpillar

contents of /salt/pillar/testpillar.sls:

myname: chris

Either my understanding of the expected behavior is wrong or this is a major show stopper for people deploying different environments tied to git branches.

iggy commented 10 years ago

+1

For clarity, we're talking about a salt master setting like so:

ext_pillar:
  - git: dev git+ssh://git@github.com/iggy/salt_pillars.git

Where changing dev to master makes things magically work.

naegelin commented 10 years ago

I followed the example here: http://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.git_pillar.html?highlight=ext_pillar%20git

declaring multiple git sources (one for each branch) and defined a unique top.sls inside each branch.

naegelin commented 10 years ago

UPDATE: This finally worked after rebuilding everything according to this link: http://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.git_pillar.html?highlight=ext_pillar%20git

My problem was that I was not calling :

salt 'mydevhost' saltutil.refresh_pillar

Here is what the final setup looked like:

/etc/salt/master:

ext_pillar:
  - git: master https://source.developers.google.com/p/project-01/ root=salt/pillar
  - git: test https://source.developers.google.com/p/project-01/ root=salt/pillar

salt/pillar/top.sls: on TEST BRANCH:

test:
  'mydev*':
    - packages/test

salt/pillar/top.sls: on MASTER BRANCH:

base:
  'myprod*':
    - packages/prod

Just make sure to always call saltutil.refresh_pillar after making changes!

salt 'mydevhost' saltutil.refresh_pillar