7

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?

Suraj HK
  • 289
  • 2
  • 10
  • 20

1 Answers1

4

You have this capacity but the correct command is:

salt '*' state.highstate saltenv=stg

Salt state documentation

HamZa
  • 14,671
  • 11
  • 54
  • 75
jakcam
  • 1,789
  • 2
  • 12
  • 14
  • It didn't work for me. When I executed that command, i got the following error , ip-10-1-1-252: ---------- ID: states Function: no.None Result: False Comment: No Top file or external nodes data matches found Started: Duration: Changes: Summary ------------ Succeeded: 0 Failed: 1 ------------ Total states run: 1 . I got this for both the minions – Suraj HK Mar 26 '15 at 13:20
  • Please show your "pillar_roots" configuration. 2 top.sls files must be saltenv synced (top.sls for pillar and top.sls for states) – jakcam Mar 26 '15 at 13:32
  • Can you please be more specific about pillar_roots? I didn't modify anything for pillar_roots configuration. I only modified file_roots in master configuration file which I showed in my post. – Suraj HK Mar 26 '15 at 19:04
  • Do you have a top.sls file in /srv/pillar where all your env are set – jakcam Mar 27 '15 at 12:48
  • Can you post stgtest file please ? Normaly you must have two top.sls files. One in srv/pillar and another for the state in /srv/salt – jakcam Mar 30 '15 at 07:58
  • Even if the documentation says the opposite, the argument `saltenv` is still written `env` in salt 0.17.5 (Ubuntu 14.04) – jopasserat Aug 02 '15 at 09:51