Formulas & state organization
Reusable, shareable state trees.
As your state tree grows, you organize it into formulas — pre-written, reusable, parameterized state trees for a piece of software (an nginx-formula, a users-formula), structured by convention with a map.jinja for OS differences and pillar-driven configuration. Salt publishes many official formulas, and the pattern is how you keep states shareable and DRY rather than copy-pasting SLS between projects.
{% set nginx = salt['grains.filter_by']({'Debian': { 'pkg': 'nginx', 'conf': '/etc/nginx/nginx.conf' },'RedHat': { 'pkg': 'nginx', 'conf': '/etc/nginx/nginx.conf', 'user': 'nginx' },}, merge=salt['pillar.get']('nginx:lookup')) %}# states import this map to stay OS-portable and pillar-tunable
File roots and environments
The master serves states and files from configured file_roots, organized by environment (base, dev, prod), and gitfs lets the master pull the state tree directly from Git — so your infrastructure code is version-controlled and the master syncs it. This is how teams manage Salt at scale: formulas as reusable units, a top file wiring them to minions, pillar supplying data, all from a reviewed Git repo.
fileserver_backend:- gitfsgitfs_remotes:- https://git.acme.internal/salt/states.git:- root: states# the master serves the state tree straight from Git, per environment/branch