Get up and running with Salt Workspace in minutes.
If you have Nix installed, all dependencies are provided automatically:
# Enter the development environment (all tools included)
nix develop
# Or with direnv for automatic activation
direnv allowSkip to Clone & Build if using Nix.
Install these tools before starting:
| Tool | macOS | Ubuntu/Debian | Purpose |
|---|---|---|---|
| VirtualBox | brew install virtualbox |
Download | VM hypervisor |
| Vagrant | brew install vagrant |
apt install vagrant |
VM management |
| Docker | brew install docker |
apt install docker.io |
Test runner |
| Python 3 | brew install python3 |
apt install python3 python3-pip |
Scripts |
| PyYAML | pip3 install pyyaml |
pip3 install pyyaml |
YAML parsing |
After installing Vagrant, add the hostmanager plugin:
vagrant plugin install vagrant-hostmanagergit clone https://github.com/BadgerOps/salt-workspace.git
cd salt-workspace
makemake testvagrant upThis starts:
- saltmaster - Salt master server
- linux-1 - Test minion (AlmaLinux 8 by default)
vagrant ssh linux-1
sudo salt-call state.highstateEdit /etc/salt/grains on the minion:
roles:
- base
- your_roleThen apply:
sudo salt-call state.highstateexport LINUX_MINION_COUNT=3
vagrant up# Ubuntu
export LINUX_DISTRO=ubuntu
export LINUX_VERSION=22.10
vagrant up
# AlmaLinux 9
export LINUX_DISTRO=almalinux
export LINUX_VERSION=9
vagrant upexport LINUX_BOX_RAM=2048
vagrant up| Command | Description |
|---|---|
make |
Build dist/ directory |
make test |
Run all tests |
make lint |
Run linting only |
make docker |
Run Docker tests |
make coverage |
Show test coverage |
make clean |
Remove dist/ |
make help |
Show all commands |
salt-workspace/
├── salt/ # Salt states
│ ├── top.sls # State assignments
│ └── roles/ # Role definitions
├── formulas/ # Reusable formulas
├── pillar/ # Configuration data
├── config/ # Salt master/minion configs
├── tests/ # Test scripts
└── dist/ # Built output (generated)
-
Create formula directory:
mkdir -p formulas/myformula/tests
-
Add state file
formulas/myformula/init.sls:myformula_package: pkg.installed: - name: mypackage
-
Add pillar example
formulas/myformula/pillar.example:myformula: enabled: true
-
Add test
formulas/myformula/tests/init.yaml:myformula: package: installed: true name: mypackage
-
Build and test:
make test
make test fails with YAML errors:
pip3 install pyyamlVagrant can't find boxes:
vagrant box updateSalt commands fail:
vagrant provision # Re-run provisioning- Read the full README for detailed documentation
- Check out the blog series for tutorials
- Explore the motd formula as an example
- Review CONTRIBUTING.md to contribute