Interview Prep/Ansible/Security: Vault, Become and Compliance

A task needs root on the target but your user has only limited sudo rights.

IntermediateScenarioSecurity: Vault, Become and Compliance
Answer

Situation read → Least-privilege become.

What I'd do →

  1. Scope become to tasks that need it, not the whole play.
  2. Ask ops to give a sudoers drop-in for specific commands if possible.
  3. Use become_user for service accounts.
- ansible.builtin.command: systemctl restart app
  become: true
- ansible.builtin.command: /opt/app/bin/report
  become: true
  become_user: appsvc

Why → Minimal escalation reduces blast radius and audit scope.

Interview tip → NOPASSWD for a service account over a fixed command list is the production norm.

All Ansible questions Roadmap: Ansible

More on Security: Vault, Become and Compliance