Ansible troubleshooting — This command has to be run under the root user

Permission error messages are annoying 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 using the package module.

Ansible Pilot
4 min readMar 28, 2022


Today we’re going to talk about Ansible troubleshooting, specifically about the “This command has to be run under the root user” message.

This fatal error message happens when we are trying to execute a module that requires more privilege during module execution.

These circumstances are usually related to Ansible Playbook or Ansible configuration.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.


The best way of talking about Ansible troubleshooting is to jump in a live demo to show you practically the “This command has to be run under the root user” and how to solve it!
This demo is going to try to install the “rsync” package on our target system.

error code

- name: troubleshooting under the root user
hosts: all
become: false
- name: rsync installed
name: rsync
state: present

error execution

ansible-pilot $ ansible-playbook -i virtualmachines/demo/inventory troubleshooting/under_root_user_error.ymlPLAY [troubleshooting under the root user] ********************************************************TASK [Gathering Facts] ****************************************************************************
ok: []
TASK [rsync installed] ****************************************************************************
fatal: []: FAILED! => {"changed": false, "msg": "This command has to be run under the root user.", "results": []}



Ansible Pilot

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday