Using Salt
Introduction to SaltStack, a Linux configuration management tool.
What is Salt?
Salt, also called SaltStack, is an open-source configuration managment and automation tool. It allows system administrators to:
Define system states (e.g. install packages, run services, configure users, etc.)
Apply those configurations across multiple machines consistently
Automate routine infrastructure tasks like updates, configuration changes, or user provisioning
Salt follows a master-minion architecture, where:
The Salt master sends commands and configurations
The Salt minion executes those commands
A deeper introduction to Salt can be found here.
Installing Salt
The Salt Project documentation offers a quick installation guide for Linux based operating systems. If you are running RHEL-like systems, follow the Linux (RPM) Install Guide. If you are running Debian-like systems, follow the Linux (DEB) Install Guide. Each guide includes post-installation steps for configuring the Salt master and minions, starting the master and minion services, accepting the minion keys, and verifying your Salt installation.
Understanding Salt
As previously mentioned, Salt is a powerful open-source tool for automating system configuration, remote execution, and infrastructure management. It uses a master/minion model where the master controls and sends instructions and the minion receives and applies configurations. There are several key concepts that will be important to know when working with Salt.
Key Concepts
Concept |
Description |
|---|---|
State |
A YAML file that describes the desired configuration of a system. |
Grains |
Static system facts collected by the minion (like OS, IP, CPU type). Can be used to target systems based on their characteristics. |
Pillar |
Secure targeted data defined on the master and passed to the minions. Used for secrets, config values, or variables in state files. |
Top File |
A special file |
Highstate |
The process of applying all states defined in the top file to the appropriate minions. |
Formulas |
Reusable Salt state modules that configure common components (like users or services). |
Common Salt Commands
Command |
Description |
|---|---|
|
Ping all minions |
|
Get minion hostname |
|
Get full grain info |
|
Get OS details |
|
Run a shell command on minions |
|
Apply a file to a state |
|
Run highstate |
Using Vagrant as a Development Environment (optional)
Vagrant is a tool for managing virtual machine environments in a reproducible way using simple configuration files called Vagrantfile. Vagrant makes it easy to rebuild development environments, which is great for testing Salt states before applying them in production. Vagrant is also compatible with KVM environments. Learn more about using Vagrant with your KVM / Libvirt environment here.
Resources
Salt Installation Guide: Instructions for installing Salt
SaltStack Installation Tutorial: Ubuntu based Salt intallation tutorial
Salt in 10 Minutes: A quick guide to understanding Salt
Creating a Simple Environment: Tutorial using Vagrant to create a simple demo environment
Vagrant Documentation: Offical Vagrant documentation site
Installing Vagrant: Basic steps to get Vagrant installed in your environment
Using Vagrant with KVM/Libvirt: A Vagrant plugin that adds a Libvirt provider to Vagrant
Salt Overview: Deep dive into Salt’s architecture
Salt Grains: Deep explanation of Salt grains
Salt States: Deep explanation of Salt states
Salt Pillar: Deep explanation of Salt pillar data
Salt Formulas: Deep explanation of Salt formulas
How to Create Your First Salt Formula: A tutorial to create your first Salt formula
Saltstack Cheatsheet: Collection of commonly used commands.