Privilege escalation errors - Ansible troubleshooting
Privilege escalation errors are one of the most common Ansible problems. In a live demo, we are going to troubleshoot starting from the error message. We are going to investigate the root cause of the problem and fix it.


Today we’re going to talk about Ansible troubleshooting and specifically about privilege escalation errors.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
It happens when the connection user Ansible doesn’t have the permission to perform the operation. The solution is simply to switch to the user with administrative rights. In Ansible you perform this operation enabling the become
statement.
Behind the scenes Ansible is connecting to the target host using the normal user, switching to the administrative user and then executing the playbook code.
The standard privilege escalation method is sudo
but more are available for example su
, pfexec
, doas
, pbrun
, dzdo
, ksu
, runas
, machinectl
, Centrify, etc.
Links
The Best Resources For Ansible
Video Course
Printed Book
eBooks
- Ansible by Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
- Ansible For Windows By Examples: 50+ Automation Examples For Windows System Administrator And DevOps
- Ansible For Linux by Examples: 100+ Automation Examples For Linux System Administrator and DevOps
- Ansible Linux Filesystem By Examples: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure
- Ansible For Containers and Kubernetes By Examples: 20+ Automation Examples To Automate Containers, Kubernetes and OpenShift
- Ansible For Security by Examples: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure
- Ansible Tips and Tricks: 10+ Ansible Examples to Save Time and Automate More Tasks
- Ansible Linux Users & Groups By Examples: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure
- Ansible For PostgreSQL by Examples: 10+ Examples To Automate Your PostgreSQL database
- Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
- Ansible Automation Platform By Example: A step-by-step guide for the most common user scenarios
demo
The best way of talking about Ansible troubleshooting is to jump in a live demo to show you practically the privilege escalation error and how to solve it!
error
---
- name: yum module demo
hosts: all
become: false
tasks:
- name: install package
yum:
name: git
state: present
fix
---
- name: yum module demo
hosts: all
become: true
tasks:
- name: install package
yum:
name: git
state: present
Now you know better how to troubleshoot the most common Ansible error about privilege escalation. Subscribe to the YouTube channel, Medium, Website, Twitter, and Substack to not miss the next episode of the Ansible Pilot.
Academy
Learn the Ansible automation technology with some real-life examples in my
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate