<p>State and pillar environments are set independently.</p>

<p>Specifing</p>

<pre><code>environment: prod
</code></pre>

<p>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:</p>

<pre><code>pillarenv: prod
</code></pre>

<p>This also does not work in old versions of salt and <a href="https://github.com/saltstack/salt/issues/36629" rel="nofollow noreferrer">is only supported with pillar.get as of salt version 2016.3,</a> so you may be in need of an update.</p>

CC BY-SA 3.0
2017-07-11T22:19:03.957Z
2017-07-11T22:19:03.957Z
James Shewey
<p>I have a salt master with four environments configured (base, dev, staging, prod) </p>

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

<p>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)</p>

<p><code>salt 'deploy*' pillar.get core:env saltenv=base</code></p>

<p>Here are my config files </p>

<pre><code>/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
</code></pre>

<p>and my pillars </p>

<pre><code>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
</code></pre>

<p>(the rest follow the same pattern) </p>

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

<configuration><salt>
Salt Stack environments ignoring saltenv
Michael B
# Salt Stack environments ignoring saltenv

(Asked by: username_0 on 2017-05-25)

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.

**Tags:** configuration, salt


---

## 1 answers

### Answer by username_1 on 2017-07-11. Score: 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.


---

