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.1k stars 5.47k forks source link

Pillar Environment not working with the parameter pillarenv=qa u others environments #30234

Closed grojasar closed 8 years ago

grojasar commented 8 years ago

Version SaltStack 2015.8.3 (Beryllium) Hi: On my master file I wrote the next:

pillar_roots:
    base:
        - /srv/pillar
    qa:
        - /srv/pillar

In directory pillar exist a file top.sls with the next information:

base:
  'srvbase*':
    - base.users
qa:
  'srvqa*':
    - qa.client

When I try to get the pillar item for environments that itsn't working, For example i wrote:

salt '*' pillar.items pillarenv=qa

And the result is all information from pillars (mixed) including base environment. This behavior is a bug?, or i need to do other configuration missing?.

I hope your help please.

jfindlay commented 8 years ago

@githubgrojas, this is one confusing aspect of salt environments. I think you should get what you expect if you try this setup:

# master config
pillar_roots:
    base:
        - /srv/pillar/base
    qa:
        - /srv/pillar/qa
# /srv/pillar/base/top.sls
base:
  'srvbase*':
    - base.users
# /srv/pillar/qa/top.sls
qa:
  'srvqa*':
    - qa.client
grojasar commented 8 years ago

@jfindlay , i did the modifications, but when i execute again on the command line, the next:

salt '*' pillar.items pillarenv=qa

Appears the next message:

"Specified SLS 'base.users' in environment 'base' is not available on the salt master"

Then, i corrected the top.sls files for environment base and qa, deleting the words base. and qa., being as follows:

# /srv/pillar/base/top.sls
base:
  'srvbase*':
    - users
# /srv/pillar/qa/top.sls
qa:
  'srvqa*':
    - client

Next, i execute again the first sentences for get just the items from pillar for environment qa but that not working, and merge all informations from pillars (base and qa), i guess that the parameter "pillarenv=qa" not working like a filter. Please correct me if I'm wrong.

jfindlay commented 8 years ago

@githubgrojas, you are correct, my example was wrong. I think that this issue is actually be a duplicate of #30234. You could try changing the pillar_source_merging_strategy master config to aggregate.

ko-christ commented 8 years ago

i don't have a naming convention like this for my qa/prod environments.

eg: The qa and dev environment could rely on the very same minion machine.

so I match all minions like that '*'

qa:
  '*':
    - client
dev:
  '*':
    - client

and when I explicitly declare saltenv=dev or saltenv=qa salt ignores my setting and pillars are merged.

Setting pillar_source_merging_strategy: aggregate does not seem to make a difference.

is it possible to explicitly use a pillar environment without having to match minions with names?

One solution I can think of is to create multiple minion instances under the same host and play with minion_id's in order to emulate the srvqa* and srvdev* names but this will be my last resort since I don't want to mess with multiple minion instances and Salt's mixed systemd/init.d init system and the inadequate documentation for that.

Any advice is welcome