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
- Anatomy of the ansible Command
- Patterns: Targeting all, web & host1
- Run Shell Commands with command & shell
- Privilege Escalation with become