Description
In the [privilege_escalation] section of ansible.cfg, become_user selects the target account. The separate become setting controls whether Ansible switches users by default.
Potential impact
A task running as the wrong account can fail for lack of access or change resources with more privileges than intended.
Remediation
If only some plays or tasks need to switch users, leave the global setting at become=False. Set become: true and the target account on those plays or tasks. Check for variables that override the defaults and verify that the connection user can switch to the target account.
Examples
Both excerpts specify sudo and root. Only the second enables switching by default with become=True.
Before
text
[privilege_escalation]
become=False
become_method=sudo
become_user=root
After
text
[privilege_escalation]
become=True
become_method=sudo
become_user=root