Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Up Environments with SaltStack

Tags:

git

salt-stack

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?

like image 733
Kyle Kelley Avatar asked Oct 10 '13 22:10

Kyle Kelley


People also ask

Is SaltStack environment configuration management tool?

SaltStack, also known as Salt, is a configuration management and orchestration tool. It uses a central repository to provision new servers and other IT infrastructure, to make changes to existing ones, and to install software in IT environments, including physical and virtual servers, as well as the cloud.

What is Salt environments?

Environments in Salt are designed to keep the configuration files for each environment isolated into respective containers for different stages of deployment such as development, QA, staging, and production.

What language does SaltStack use?

SaltStack is an open-source configuration management software and remote execution engine. Salt is a command-line tool. While written in Python, SaltStack configuration management is language agnostic and simple.


1 Answers

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.

like image 163
Colton Myers Avatar answered Sep 25 '22 16:09

Colton Myers