Home / Ansible Safety Pack
freeAnsible Safety Pack
Keep one bad commit from reaching every host at once
Three guard rails for Ansible repos
Download — freeMIT licensed
The problem
Ansible runs every task on every host in parallel by default, so one wrong template variable hits the whole fleet in a minute. Add noisy "changed" results, lying changed_when: false and mystery variable precedence, and a repo with no safety net is easy to break.
What it does
- Pre-commit config: yamllint, ansible-lint, shellcheck, detect-secrets, Jinja syntax check, plus two custom lint rules (
safety-command-unguarded,safety-changed-when-false-lie) - Rolling-update playbook:
seriallist,max_fail_percentage, a verification task that can fail, optionalany_errors_fatal - vars-doctor: shows where a host variable resolves from and flags disagreeing layers, plus a precedence cheat sheet
- Docker demo with four rollout scenarios: a canary stops a bad change at 1 of 5 hosts, while the unbatched run breaks 5 of 5
What's in the box
.pre-commit-config.yaml,.yamllint.yaml,.ansible-lint,rules/,scripts/check_jinja.pyplaybooks/rolling_update.ymlbin/vars-doctordemo/(Docker) andtests/(14 pytest tests)- README, CHANGELOG, Makefile, MIT LICENSE
Usage
ansible-playbook -i inventory playbooks/rolling_update.yml \
-e rollout_apply_tasks=tasks/apply.yml \
-e 'rollout_verify_command="resolvectl query example.com"' \
-e '{"rollout_serial":[1,"10%","50%"]}'
bin/vars-doctor -i inventory/lab.yml r29 ansible_user
bin/vars-doctor --cheatsheet
Requirements
- Python venv with ansible-core, ansible-lint, pre-commit, yamllint, pytest, jinja2, pyyaml
- Docker for
make demo(5 containers) - Tested on ansible-core 2.22
Limitations / what it is not
- vars-doctor reads YAML/JSON inventories and
group_vars/host_vars; INI and dynamic inventories are shown at inventory/task layer only; role defaults,set_factand-eare never attributed to a file. - With
-p, vars-doctor writes a temporary playbook next to yours and deletes it afterwards. - Lint rule 2 is a regex heuristic and can false-positive.
- The rolling template cannot fix a bad verify command; it only stops the rollout when verification fails.
- Pre-commit hook revisions are pinned at write time; run
pre-commit autoupdate.
FAQ
What is the license?
MIT. Free to use, modify and share.
Is it free? Yes. No payment is involved.
How do I get support?
By email: [email protected].
Where it came from
Written up on the blog first:
- When your Ansible network playbook silently ignores group_vars
- Your Playbook Is Not Idempotent And You Already Know It
- Pre-commit hooks that keep broken YAML out of your infra repo
- Rolling changes with Ansible serial and max_fail_percentage
Download — freeMIT licensed
Tested Lab-tested
| Product version | 1.0.1 |
|---|---|
| Last run | 2026-11-24 |
| Result (install and tests) | PASS |
| Platforms | Debian 13 container; Docker-based demo hosts |
What was tested, and how
- pytest suite in a clean Debian 13 container with a fresh venv
How: Pack copied in, ansible-core, ansible-lint and pytest installed make demo: four scenarios (A-D) on disposable Docker hosts; every assertion must pass
How:make setuponce (creates the venv), thenmake demo
Not tested
- Real fleets and non-Docker connection types
Method and lab setup: How we test.