Become
Cheat sheet · https://pcornel.dk/topic.php?topic=5412
Answer
Ansible become changes privilege context for tasks through a supported escalation method, separating connection identity from the identity under which the target action executes.
Remember
- Connection authenticated ≠ become authorized; login and privilege escalation are separate boundaries.
- become: true ≠ root necessarily; become_user and platform method determine effective identity.
- Sudo command works interactively ≠ noninteractive Ansible become works with same policy.
- Privilege escalation success ≠ task safe; authorization does not validate intended change.
First checks
ansible <h> -m command -a 'id' -b— become testsudo -l -U <automation-user>— sudo rights on target- become_method/become_user — config
Verify in this order
task → become → privileged execution
Where it usually breaks
Successful become proves escalation to the configured execution context for that action; it does not prove the action itself or wider target state is correct.
Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.
Become Ansible boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Inputs / selection | Correct inventory, hosts, variables/facts and content are explicit | Wrong scope, stale facts, hidden precedence or content-version drift |
| Execution | Connection, privilege, module/task context and ordering match intent | Unreachable, wrong execution host, privilege/plugin failure or misleading skip/change state |
| Result semantics | Per-host/item results are preserved and interpreted correctly | Aggregate recap hides partial/skipped/handled failures |
| Target proof | Resource/workload read-back and rerun confirm convergence | Green Ansible status treated as end-to-end acceptance |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5412