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.

Playbook

The best way of talking about Ansible troubleshooting is to jump in a live Playbook to show you practically the privilege escalation error and how to solve it!

error

---
- name: yum module Playbook
  hosts: all
  become: false
  tasks:
    - name: install package
      yum:
        name: git
        state: present

fix

---
- name: yum module Playbook
  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, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.

BUY the Complete Udemy 300+ Lessons Video Course

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Patreon Buy me a Pizza