The default method used for privilege escalation by Ansible is sudo. When running tasks that require elevated privileges, Ansible uses sudo to execute commands as a superuser.
You can specify this in your playbook or command line by using the become directive, like so:
- hosts: all
tasks:
- name: Install a package
apt:
name: package_name
state: present
become: yes
This tells Ansible to use sudo to install the package. If you have further questions or need more details, feel free to ask!
