A learning workspace for SaltStack configuration management, developed alongside a blog series.
New to this project? Start with QUICKSTART.md for step-by-step setup instructions.
# Clone and build
git clone https://github.com/BadgerOps/salt-workspace.git
cd salt-workspace
make
# Run tests
make test
# Start VMs
vagrant upsalt-workspace/
├── salt/ # Salt states
│ ├── top.sls # State assignments
│ └── roles/ # Role-based states
├── formulas/ # Reusable Salt formulas
│ ├── motd/ # Message of the Day
│ ├── packages/ # Package management
│ └── users/ # User management
├── pillar/ # Configuration data
├── config/ # Salt master/minion configs
├── tests/ # Test scripts
├── .devcontainer/ # VS Code / Codespaces config
└── .github/workflows/ # CI/CD pipeline
Option A: Use Nix (recommended) - All tools included automatically:
nix develop # or: direnv allowOption B: Manual installation:
| Tool | Purpose |
|---|---|
| VirtualBox | VM hypervisor |
| Vagrant | VM management |
| Docker | Formula testing |
| Python 3 + PyYAML | Lint scripts |
# Install Vagrant plugin
vagrant plugin install vagrant-hostmanager| Command | Description |
|---|---|
make |
Build dist/ directory |
make test |
Run full test suite |
make lint |
Linting checks only |
make docker |
Docker formula tests |
make coverage |
Test coverage report |
make package |
Create tarball |
make clean |
Remove dist/ |
make help |
Show all commands |
- Make changes in
salt/,formulas/, orpillar/ - Build:
make - Test:
make test - Apply in VM:
vagrant ssh linux-1→sudo salt-call state.highstate
| Variable | Default | Description |
|---|---|---|
LINUX_DISTRO |
almalinux | OS distribution |
LINUX_VERSION |
8 | OS version |
LINUX_MINION_COUNT |
1 | Number of minions |
LINUX_BOX_RAM |
1024 | RAM per VM (MB) |
SALT_VERSION |
3006.7 | Salt version |
export LINUX_MINION_COUNT=3
vagrant up /linux/# Ubuntu
export LINUX_DISTRO=ubuntu LINUX_VERSION=22.10 && vagrant up
# AlmaLinux 9
export LINUX_DISTRO=almalinux LINUX_VERSION=9 && vagrant upEvery formula needs:
formulas/myformula/
├── init.sls # Main state file
├── pillar.example # Example configuration
└── tests/
└── init.yaml # Test definitions
See the packages and users formulas for examples.
- SSH into a minion:
vagrant ssh linux-1 - Edit grains:
sudo vim /etc/salt/grainsroles: - base - your_role
- Apply:
sudo salt-call state.highstate
Use GPG for sensitive pillar data:
# Generate key (one-time setup)
gpg --gen-key --homedir /etc/salt/gpgkeys
# Encrypt a value
echo -n 'mysecret' | gpg --armor --encrypt -r 'Salt Master'Add #!yaml|gpg shebang to pillar files with encrypted values.
See CONTRIBUTING.md for guidelines.
This project includes a Nix flake for reproducible development environments. All dependencies are pinned and isolated from your system.
Available shells:
| Shell | Command | Description |
|---|---|---|
| Default | nix develop |
Docker-based testing (works everywhere) |
| Vagrant | nix develop .#withVagrant |
Full VMs (requires VirtualBox) |
| Lima | nix develop .#withLima |
Lightweight VMs (macOS/Linux) |
Quick start:
# Default shell (Docker-based, recommended for most users)
nix develop
# Run tests directly
nix develop --command make test
# If you need full VMs for testing
nix develop .#withLima # Lightweight VMs, no VirtualBox needed
nix develop .#withVagrant # Traditional Vagrant VMsLima VM templates (with Salt pre-installed):
# Start a Salt-ready VM (Ubuntu)
limactl start ./lima/salt.yaml
limactl shell salt
# Or AlmaLinux (RHEL-compatible, like the Vagrant setup)
limactl start ./lima/salt-almalinux.yaml
limactl shell salt-almalinux
# Inside the VM: sync workspace and test
sudo rsync -av ~/salt-workspace/dist/ /srv/
sudo salt-call state.highstateWith nix-shell (legacy):
nix-shell # Default
nix-shell --arg withLima true # With Lima
nix-shell --arg withVagrant true # With VagrantWith direnv (automatic activation):
direnv allow # One-time setup, then auto-activates on cdWhat's included:
| Tool | Purpose |
|---|---|
| Python 3.11 + PyYAML | Scripts and linting |
| Docker + docker-compose | Container-based testing |
| yamllint, shellcheck | Linting and validation |
| make, rsync, git | Build tools |
| jq, yq | YAML/JSON utilities |
| Lima (optional) | Lightweight Linux VMs |
| Vagrant (optional) | Full VM management |
Installing Nix:
# Linux/macOS (multi-user installation)
sh <(curl -L https://nixos.org/nix/install) --daemon
# Enable flakes (add to ~/.config/nix/nix.conf)
experimental-features = nix-command flakesSee the Nix installation guide for more options.
This project includes a Dev Container configuration for instant development environments:
- VS Code: Install the Dev Containers extension, then "Reopen in Container"
- Codespaces: Click "Code" → "Codespaces" → "Create codespace"
Follow the instructions in QUICKSTART.md.
- Blog Series - Tutorials and guides
- Salt Documentation - Official docs
- Salt Formulas - Community formulas
MIT License - see LICENSE file for details.