4

I have a salt master with four environments configured (base, dev, staging, prod)

I am initially trying to set a pillar item to track which envrionment is in use, namely core:env

However when I try to switch environments using the following command I always get the dev environment (it doesn't matter what env I put)

salt 'deploy*' pillar.get core:env saltenv=base

Here are my config files

/etc/salt/master (partial)
file_roots:
  base:
    - /srv/salt/base/states
  dev:
    - /srv/salt/dev/states
    - /srv/salt/base/states
  staging:
    - /srv/salt/staging/states
    - /srv/salt/base/states
  prod:
    - /srv/salt/prod/states
    - /srv/salt/base/states


pillar_roots:
  base:
    - /srv/pillar/base/pillars
  dev:
    - /srv/pillar/dev/pillars
    - /srv/pillar/base/pillars
  staging:
    - /srv/pillar/staging/pillars
    - /srv/pillar/base/pillars
  prod:
    - /srv/pillar/prod/pillars
    - /srv/pillar/base/pillars

and my pillars

root@Salt-Master:/srv/pillar# cat base/pillars/top.sls
base:
  'deploy':
    - core
root@Salt-Master:/srv/pillar# cat base/pillars/core.sls
core:
  env: base
root@Salt-Master:/srv/pillar# cat dev/pillars/top.sls
dev:
  'deploy':
    - core
root@Salt-Master:/srv/pillar# cat dev/pillars/core.sls
core:
  env: dev

(the rest follow the same pattern)

I have other data in the base pillar that is being pulled out, but the core:env item won't change from dev.

2

State and pillar environments are set independently.

Specifing

environment: prod

in the minion configuration will force the minion to use the prod state, but it will still use the default pillar data. To select a pillar environment you will also need:

pillarenv: prod

This also does not work in old versions of salt and is only supported with pillar.get as of salt version 2016.3, so you may be in need of an update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.