become
The Ansible keyword that switches on privilege escalation, so a task or a whole play runs as another account, root by default.
In more detail
Set become: true on a play and every task in it escalates; set it on a task and only that task does. become_user says who to become, and setting it without become: true is the classic mistake that ansible-lint catches. Setting become: false explicitly in a play that must not need privilege turns an accident into a clear failure.
Example
become: true
become_user: appRelated terms
- privilege escalation — Gaining the rights of a more powerful account, such as root, either deliberately through a tool like sudo or illegitimately through a flaw.
- become method — The setting that chooses which tool Ansible uses to escalate privilege: sudo by default, or alternatives such as su, doas or pbrun.
- sudo — A command that runs another command with administrator (root) rights after checking you are allowed to.
- root user — The all-powerful administrator account on Linux, with user ID 0, which can read or change anything.
- become password — The password the escalation tool, usually sudo, asks for on the managed node, which Ansible must be told to supply.
Taught in
- Connections And Privilege Escalation — Ansible Configuration Management at Scale
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible.cfg: Which File Wins, And The Settings That Matter — RHCE in Ansible (EX294): Automate Red Hat Systems
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- Privilege Escalation: sudo Rules And become — RHCE in Ansible (EX294): Automate Red Hat Systems
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
- Facts And Magic Variables: Let Each Node Describe Itself — RHCE in Ansible (EX294): Automate Red Hat Systems
- Handlers And Failure: notify, block, rescue And always — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible-navigator: The Settings File The Exam Reads — RHCE in Ansible (EX294): Automate Red Hat Systems
- Finding Modules In Collections: ansible-doc And navigator — RHCE in Ansible (EX294): Automate Red Hat Systems
- requirements.yml: Installing Roles And Collections — RHCE in Ansible (EX294): Automate Red Hat Systems
- Packages And Repositories: yum_repository And dnf — RHCE in Ansible (EX294): Automate Red Hat Systems
- Services And Boot Targets: Started Is Not Enabled — RHCE in Ansible (EX294): Automate Red Hat Systems
- Scheduling: cron Jobs With Names, And Timers — RHCE in Ansible (EX294): Automate Red Hat Systems
- SELinux: Labels, Ports And Booleans That Persist — RHCE in Ansible (EX294): Automate Red Hat Systems
- Users And Groups From A List, With Passwords That Settle — RHCE in Ansible (EX294): Automate Red Hat Systems
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: People, Passwords And sudo From The Vault — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 2: Real Machines And The Patterns That Fail — RHCE in Ansible (EX294): Automate Red Hat Systems