0Pricing
Ansible Academy · Lesson

Privilege Escalation with become

Run tasks as root using sudo.

Some Tasks Need Root

Installing packages or restarting services usually needs root. Ansible handles that with privilege escalation, not a separate root login. 🔐

Enable It with become

Add the --become flag, often shortened to -b, to run your ad-hoc command with elevated privileges on the remote host.

ansible all -b -m package -a "name=git state=present"

All lessons in this course

  1. Anatomy of the ansible Command
  2. Patterns: Targeting all, web & host1
  3. Run Shell Commands with command & shell
  4. Privilege Escalation with become
← Back to Ansible Academy