Map dependency depth and count across Ansible roles and their meta dependencies.
Ansible resolves role dependencies declared in each role's meta/main.yml before running the role itself, and by default loads each unique role only once per play even if multiple roles depend on it. This calculator expands direct roles across your dependency depth to estimate raw transitive dependency count, then applies a shared/duplicate fraction to approximate how many roles Ansible actually loads once deduplication is applied.
total_roles = direct_roles + raw_transitive × (1 - shared_fraction / 100)
No — by default, `allow_duplicates: false` in role meta means a role is only executed once per play even if several other roles list it as a dependency, which is why deduplication matters for an accurate total.
Ansible performs a depth-first resolution: a role's dependencies run before the role itself, in the order declared. Circular dependencies will cause an error, so dependency graphs should be acyclic.
Deep dependency chains (roles depending on roles depending on roles) make it hard to reason about execution order and increase the blast radius of a change to a low-level shared role — many teams cap depth at 2-3 levels.
Use `ansible-galaxy role list` combined with inspecting each role's meta/main.yml, or run `ansible-playbook --list-tasks` which expands and prints the full resolved task list including role dependencies.