Ansible PowerShell & sudo Become Error: 'powershell is not compatible' Fix
By Luca Berton · Published 2024-01-01 · Category: installation
Fix the Ansible error 'powershell is not compatible with the sudo become plugin'. Occurs when targeting Windows hosts with Linux-style privilege escalation. Complete solution guide.
Introduction
Welcome back to Ansible Pilot! I'm Luca Berton, and today we're diving into Ansible troubleshooting, focusing on the error that states "the PowerShell shell family is incompatible with the sudo become plugin." Join me as we explore how to reproduce, troubleshoot, and fix this runtime error in Ansible.
The Demo
To better understand and solve the "the PowerShell shell family is incompatible with the sudo become plugin" error, let's jump into a live Playbook.
Error Code
Error Execution
Fix Code
Fix Execution
Conclusion
In this troubleshooting guide, we successfully tackled the "PowerShell incompatible with the sudo become plugin" error in Ansible. By adjusting the playbook to disable the become plugin, we overcame the compatibility issue.
I hope this Playbooknstration helps you effectively troubleshoot and resolve similar errors in your Ansible automation journey. If you found this information valuable, don't forget to subscribe for more Ansible insights.
Why This Error Happens
This error occurs when Ansible tries to use the Linux sudo become plugin with a Windows target running PowerShell. Windows doesn't have sudo — it uses different privilege escalation methods.
The typical error message:
Root cause: Your playbook or inventory has become: true (which defaults to become_method: sudo) for a Windows host.
Fix Options
Fix 1: Use runas become method for Windows
Fix 2: Don't use become for Windows (most common)
Most Windows tasks run as the connecting user. If that user is an Administrator, you don't need become:
Fix 3: Separate Windows and Linux plays
Fix 4: Set become_method per host in inventory
Windows Connection Checklist
For Windows hosts, ensure your inventory includes:
FAQ
Can I use SSH instead of WinRM for Windows?
Yes, starting with Windows 10/Server 2019 with OpenSSH installed:
But WinRM is still more commonly used and better supported.
What about ansible.builtin.psrp connection?
PSRP (PowerShell Remoting Protocol) is an alternative to WinRM:
How do I test Windows connectivity?
Related Articles • Ansible Become Guide • Ansible Inventory Guide • Ansible for Windows Guide
Category: installation
Watch the video: Ansible PowerShell & sudo Become Error: 'powershell is not compatible' Fix — Video Tutorial