Question

How do I make minions use a particular SaltStack environment?

The GitFS backend tutorial states that branches will be mapped to environments using the branch name as identifier. How do I expose these environments to my minions?

As an example, let's say I have a branch named "pippy". I'd like to deploy that branch to particular minions.

It seems like I can set the environment via the minion's configuration file. Are there other ways that can be done from the salt master?

Was it helpful?

Solution

The key here is that the top.sls file is cross-environment. Before we jump into that, it's important to note that while most branches will be mapped to environments of the same name, the exception is that the master branch will be mapped to the base environment.

Anyway, on to top.sls. In top.sls you define your environments, which minions are members of that environment, and which statefiles will be run from that environment for a state.highstate.

base:
  '*':
    - basestate
dev:
  'webserver*dev*':
    - webserver
  'db*dev*':
    - db
qa:
  'webserver*qa*':
    - webserver
  'db*qa*':
    - db
pippy:
  'webserver*pippy*':
    - webserver
  'db*pippy*':
    - db

So, all minions will run the basestate.sls file from the base environment. Only the targeted minions will run the states from each of the other environments.

There is much more information in the topfile documentation.

Defining the environment option in the minion config just isolates a minion to a specific environment. It's much more flexible and powerful to define your environments from your topfile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top