Ubuntu 26.04 sudo-rs Breaks Ansible become

Ubuntu 26.04 replaces sudo with sudo-rs, causing Ansible -K timeout. Fix via Ansible Core 2.22.0+, inventory ansible_become_exe=sudo.ws

Table of contents
  1. 1.Introduction & Key Points
  2. 2.Core Facts & Comparison
  3. 3.Technical Deep Dive & Operational Details
  4. 3.1.Prompt Mismatch Mechanics
  5. 3.2.Ansible Upgrade Fix Path
  6. 3.3.Inventory-Level Workaround Without Upgrade
  7. 4.Scenario-Based Selection & Pitfall Checklist
  8. 5.FAQ
  9. 6.Sources & References
Ubuntu 26.04 sudo-rs Breaks Ansible become

Introduction & Key Points

Operations teams migrating servers from Ubuntu 22.04/24.04 to 26.04 have encountered a regression: running Ansible playbooks with -K (--ask-become-pass) fails during “Gathering Facts” with Timeout (12s) waiting for privilege escalation prompt. The root cause is Ubuntu 26.04 shipping sudo-rs, a Rust rewrite of sudo, as the default. sudo-rs emits an extra line before the password prompt, breaking the Ansible become plugin’s fixed prompt-matching logic. The same issue affects pyinfra and similar automation tools. This article covers three remediation paths for teams maintaining large Ubuntu fleets that rely on password-based sudo.

Core Facts & Comparison

Symptom Root Cause Official Fix Version Workaround A Workaround B
ansible-playbook -K errors Timeout (12s) waiting for privilege escalation prompt Ubuntu 26.04 defaults sudo to sudo-rs; prompt format changed Ansible Core 2.22.0 (backported to 2.16/2.18/2.19/2.20/2.21) Set ansible_become_exe=sudo.ws in inventory to use legacy sudo Run update-alternatives --config sudo system-wide to switch back to sudo.ws

Technical Deep Dive & Operational Details

Prompt Mismatch Mechanics

Legacy sudo outputs standard prompts such as BECOME password: directly. The Ansible become plugin waits for this pattern via regex. sudo-rs prints an additional informational line (exact string not disclosed in source) before the prompt, so Ansible’s 12-second timeout expires before the expected pattern appears, causing privilege escalation to be deemed failed. This behavioral difference stems from the upstream implementation change, not an Ansible defect.

Ansible Upgrade Fix Path

The Ansible community addressed the issue in the “validate sudo become plugin against sudo-rs” ticket. The fix shipped in Ansible Core 2.22.0 and was backported to the 2.16, 2.18, 2.19, 2.20, and 2.21 maintenance branches. Operators only need to upgrade the control node with pip install -U ansible to any version containing the fix; no changes are required on managed nodes.

Inventory-Level Workaround Without Upgrade

When the control node cannot be upgraded (e.g., managed platform lock-in), explicitly set ansible_become_exe=sudo.ws for target hosts in the inventory. Ubuntu 26.04 retains the traditional sudo binary under the name sudo.ws, coexisting via the alternatives mechanism. This parameter instructs Ansible to invoke sudo.ws directly, bypassing sudo-rs, and takes effect immediately — suitable for mixed-version clusters during transition.

Scenario-Based Selection & Pitfall Checklist

  1. Control node freely upgradable: Preferred — run pip install -U ansible to ≥2.22.0 or the latest patched micro-version of a backported branch. Resolves the issue for all managed nodes at once with minimal maintenance overhead.
  2. Control node version frozen (e.g., platform-locked): Apply ansible_become_exe=sudo.ws in inventory for Ubuntu 26.04 host groups only; other distributions remain unaffected.
  3. Full-environment standardization: In base images or Ansible bootstrap tasks, execute update-alternatives --config sudo and select sudo.ws to eliminate the divergence at the source. Evaluate impact on any local scripts that depend on sudo-rs-specific features (not disclosed in source).
  4. Pitfall: Do not uninstall the sudo-rs package; it may break Ubuntu 26.04 package dependencies. sudo.ws is Canonical’s officially retained compatibility path with guaranteed long-term availability.
  5. Cross-tool ripple: pyinfra is similarly affected; its fix landed in version 3.11 — apply the same upgrade strategy.

FAQ

Ansible upgraded but error persists — how to troubleshoot

Verify ansible --version on the control node shows Core 2.22.0+ or the latest micro-version of 2.16/2.18/2.19/2.20/2.21. If using a virtual environment, upgrade inside that venv. Rule out SSH ControlPersist reusing stale connections that cache the old prompt behavior.

Are sudo.ws and sudo-rs functionally equivalent?

sudo.ws is the traditional C implementation, preserving existing syntax and plugin ecosystem. sudo-rs is a Rust rewrite targeting memory safety and performance; certain cutting-edge features (specific differences not disclosed in source) may exist only in sudo-rs. Before switching in production, run the full playbook suite on a test machine to validate compatibility.

Sources & References

Spotted outdated pricing, stock, or expired coupons?See methodology & report an update →

Related articles