How to run state.highstate for a particular environment?

Suraj HK picture Suraj HK · Mar 25, 2015 · Viewed 10.2k times · Source

My environments structure in /etc/salt/master looks like this

file_roots:
  base:
    - /srv/salt
  dev:
    - /srv/salt/dev
  stg:
    - /srv/salt/stg
  prod:
    - /srv/salt/prod

And my top.sls file is in /srv/salt

dev:
  'ip-10-1-1-28':
    - devtest

stg:
  'ip-10-1-1-252':
    - stgtest

prod:
  'ip-10-1-1-200':
    - prodtest

Now I want to run state.highstate for a particular environment, say 'stg'. I am looking for something like this,

salt '*' state.highstate env=stg

How do I achieve this? My requirement is that every time I run the command, I don't want minions in all the environments to run the SLS files. Any solution?

Answer

jakcam picture jakcam · Mar 26, 2015

You have this capacity but the correct command is:

salt '*' state.highstate saltenv=stg

Salt state documentation