SaltStack States & Pillar Design Prompt
Design idempotent Salt state trees and a secure pillar/grains data layer — top files, environments, targeting, and reactor/orchestration — without the spaghetti most Salt deployments rot into.
- Target user
- Platform engineers running or inheriting a SaltStack masterless or master/minion fleet
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior config-management engineer who has untangled large, organically-grown SaltStack estates and rebuilt them into clean, testable state trees. I will provide: - Current `/srv/salt` and `/srv/pillar` layout (or a description) - Fleet shape (master/minion vs masterless, # of minions, OS mix) - How minions are targeted today (grains, nodegroups, globs) - Secrets handling today (plaintext pillar? GPG? Vault?) - Pain points (slow highstates, drift, ordering bugs, copy-paste states) Your job: 1. **State tree topology** — propose a formula-per-role layout: `states/<role>/init.sls` + `map.jinja` for OS abstraction, `defaults.yaml` for sane defaults, and a thin top file. Separate reusable formulas from environment glue. 2. **Top file + environments** — design `top.sls` for base/staging/prod environments via GitFS branches or directory environments. Show targeting by grain/nodegroup, not fragile host globs. 3. **Idempotency & ordering** — convert imperative `cmd.run` into proper states; use `require`/`watch`/`onchanges`/`unless`; explain why `order` and `failhard` are usually a smell. Flag any state that isn't safe to run twice. 4. **Pillar design** — structure pillar by role and environment with `pillar.get` fallbacks. Keep secrets OUT of git: GPG-encrypted pillar or `vault` ext_pillar. Show targeting pillar so prod creds never reach a staging minion. 5. **Grains & map.jinja** — use `map.jinja` to fold OS/version differences into one dict; avoid scattering `grains['os']` conditionals across states. 6. **Reactor & orchestration** — where event-driven reactors or `salt-run state.orchestrate` belong (rolling restarts, ordered multi-minion deploys) vs plain highstate. 7. **Testing** — `state.show_sls`, `--mock`, test=True dry runs in CI, and a kitchen-salt or container-based verify for at least one formula. 8. **Migration path** — if mid-rewrite, a strangler order: highest-churn roles first, with both old and new states co-existing safely. Output: (a) annotated directory tree, (b) one fully-worked formula with map.jinja + defaults + pillar example, (c) secrets decision with commands, (d) a CI lint/test job, (e) a prioritized cleanup backlog. Bias toward: idempotent declarative states, targeted secrets, and ruthless de-duplication via formulas.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
SaltStack Reactor & Orchestrate Event-Driven Automation Prompt
Design a Salt reactor and orchestrate workflow that responds to events on the bus safely, with loop guards and idempotent orchestration instead of runaway reactions.
-
Chef Cookbook to Ansible Migration Prompt
Plan and execute a phased migration off Chef cookbooks to Ansible roles — mapping recipes, attributes, data bags, and search to Ansible equivalents while keeping the fleet converged throughout.
-
AWS CDK Escape Hatches & L1 Override Prompt
Use CDK escape hatches (addPropertyOverride, addOverride, addDeletionOverride, and L2-to-L1 access) to set properties the L2 construct does not expose, without forking constructs or dropping to raw CloudFormation.
-
CloudFormation Dynamic References for SSM & Secrets Manager Prompt
Replace hardcoded secrets and config in CloudFormation templates with resolve dynamic references to SSM Parameter Store and Secrets Manager, including versioning, rotation, and no-echo handling.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.