Ansible Var Lens
See the effective value of every Ansible variable, per host.
In any non-trivial Ansible repo, the daily question is "what is the final value of this variable for host X?" — and the answer is buried under the precedence rules of group_vars/all, group_vars/<group>, host_vars/<host>, inventory [group:vars] and inline host vars. Ansible Var Lens answers it inside VS Code.
Features
Inventory explorer — activity-bar view with groups and hosts (INI and YAML inventories, multiple files, [group:children], host ranges tolerated).
Effective variables per host — click a host to open a YAML document with every variable merged with Ansible's precedence, each one annotated with the file it comes from and the files it overrides:
# from: host_vars/web-01/override.yml
# overrides: group_vars/all/base.yml
# overrides: group_vars/web/main.yml
timeout: 90
{{ variable }} hovers — pick a host (status bar), then hover any {{ var }} in playbooks/templates to see its resolved value for that host and where it was defined.
Compare two hosts — right-click a host ▸ Compare Effective Variables Between Hosts (or run the command) to open a document with only the variables that differ — changed / only-in-A / only-in-B, each with its provenance.
Vault-aware — fully vault-encrypted files are skipped and reported; inline !vault scalars show as <vaulted>.
Zero setup — reads ansible.cfg (inventory = ...) or auto-detects ./inventory, ./hosts; group_vars/host_vars as single files or directories, next to the repo root or the inventory.
Merge order modeled
Lowest → highest precedence (Ansible's inventory layer, hash_behaviour=replace):
- inventory
[group:vars] (parents before children)
group_vars/all
group_vars/<group> (parents before children, alphabetical within the same depth)
- inline inventory host vars (
ansible_host=…)
host_vars/<host>
Role defaults/vars and play vars are out of scope: they belong to plays, not to the inventory layer this extension models.
Settings
| Setting |
Default |
Description |
ansibleVarLens.inventoryPaths |
[] |
Inventory files/dirs relative to the workspace root. Empty = auto-detect. |
Documentation
Indice completo in docs/README.md.
Development
Setup (TDD enforced locally)
./docs/scripts/setup-dev-environment.sh
This installs npm packages and git pre-commit hook that enforces TDD: tests must pass before commit.
Development workflow
npm test # run all unit tests (must pass before commit)
npm run build # bundle to dist/ (after tests pass)
npx tsc --noEmit # type check
# F5 in VS Code launches the Extension Development Host
The core (inventory parser + resolver) is dependency-free of the VS Code API and lives in src/core/ — that's what the tests cover. Optional smoke test against a real repo:
AVL_SMOKE_REPO=/path/to/your/ansible/repo npm test
Release & Publishing
Backlog & Milestones
Roadmap in docs/backlog.md (sorgente unica per milestones + feature planning).
Create a release (automated)
./docs/scripts/new-release.sh minor # bumps version, commits, and tags automatically
# (Edits CHANGELOG.md in your editor — fill in details)
# Then just push:
git push origin main --follow-tags
That's it! GitHub Actions automatically:
- ✅ Runs tests + type check + build
- 📦 Creates
.vsix → GitHub Releases
- 🚀 Publishes to VS Code Marketplace (if
VSCE_PAT secret configured)
License
MIT