I keep a couple of disposable Ubuntu containers around for trying out playbooks before I point them at anything that matters, and this week Lobsters was carrying a report from Jeff Geerling: Ansible's privilege escalation hangs against Ubuntu 26.04. The cause was Ubuntu's new default sudo implementation, a Rust rewrite called sudo-rs, printing a password prompt that Ansible doesn't recognise. The report named a fix and a couple of workarounds. I wanted to know exactly how long the hang is, whether the fix is actually in the Ansible release most people would reach for, and whether the workarounds hold up against a real box.
Reproducing it
I built a plain Ubuntu 26.04 container with openssh-server and sudo-rs installed (the minimal base image doesn't ship it, but it's Ubuntu 26.04's own default once installed, not a custom build), added a user called deploy whose sudo access needs a password, and pointed a one-task playbook at it with become: yes. With ansible-core 2.17.6, a version released well before any of the fixes mentioned in the report, three runs looked like this:
run 1: 12.82s, exit code 2 run 2: 12.76s, exit code 2 run 3: 12.80s, exit code 2 Every run fails the same way, on the very first task, before a single real command runs:
TASK [Gathering Facts] ********************************** fatal: [127.0.0.1]: FAILED! => {"msg": "Timeout (12s) waiting for privilege escalation prompt: "} Twelve to thirteen seconds of nothing, three times running, then a hard failure. The right password was sitting in the inventory the whole time. Ansible never got as far as sending it.
Why: the prompt itself
Ansible tells sudo exactly what prompt text to print, so it knows what to wait for on the wire. I captured the raw bytes of both sudo implementations answering that same request:
# traditional sudo, asked for a custom prompt [sudo via ansible, key=test] password: sudo: no password was provided # sudo-rs, asked for the identical prompt [sudo: [sudo via ansible, key=test] password:] Password: Traditional sudo prints the prompt Ansible asked for, verbatim. sudo-rs wraps it inside its own fixed template and appends a capitalised "Password:" of its own. Ansible is matching for the exact string it supplied, so the extra wrapping is enough to miss it.
I went looking at the actual fix rather than guessing at it. Diffing the sudo become plugin between ansible-core 2.17.6 and a version that passes, the fix is a second regex, added specifically for this:
def check_password_prompt(self, b_output: bytes) -> bool: matched = super().check_password_prompt(b_output) if not matched: # try sudo-rs, which is not backwards compatible and does i18n sudo_rs = re.compile( rf"\[sudo:\s+{re.escape(self.prompt)}\]\s+\S.+\Z".encode() ) matched = any(sudo_rs.match(l) for l in b_output.splitlines()) return matched That is a comment in Ansible's own source calling sudo-rs "not backwards compatible", which tells you the project doesn't see this as a wording quirk they're working around quietly.
Does the backport claim actually hold today
The report said the fix landed in ansible-core 2.22.0 and was backported to the 2.16, 2.18, 2.19, 2.20 and "possibly" 2.21 branches. I installed the latest released patch of each branch from PyPI as of today and ran the same playbook against the same container:
| ansible-core | Python needed | Result |
|---|---|---|
| 2.16.20 | 3.10+ | fails, 12s timeout |
| 2.17.6 | 3.10+ | fails, 12s timeout |
| 2.18.20 | 3.11+ | fails, 12s timeout |
| 2.19.15 | 3.11+ | fails, 12s timeout |
| 2.20.11 | 3.12+ | passes, ~2.1s |
| 2.21.6 | 3.12+ | passes, ~2.1s |
| 2.22.0 | 3.13+ | passes, ~2.1s |
So the fix is real, but as of today it has not shipped in any released patch of the 2.16, 2.18 or 2.19 branches, only in 2.20 and above. Anyone pinned to one of those older branches gets nothing from upgrading within that branch, and those branches exist specifically to support older Python versions, which is exactly the situation where this matters most. The only way to actually fix this right now is to move to ansible-core 2.20 or newer, which also means moving the control node to Python 3.12. That's a bigger ask than "pip install --upgrade ansible" and it's not what the backport list implies.
A control node still on Ubuntu 24.04's system Python, which ships 3.12, is fine. One stuck on Python 3.11, which is what Debian 12 ships, is not: I installed the plain ansible package (the meta-package, not ansible-core directly) into a clean Python 3.11 virtualenv, and pip resolved it to ansible-core 2.19.15, the exact version I'd already confirmed still fails. On a control node like that, pip install -U ansible doesn't get you the fix, because 2.19.15 is the newest ansible-core release pip can satisfy under 3.11.
The part that doesn't trigger it at all
In my experience, a lot of cloud images set up their default user with passwordless sudo via cloud-init rather than a sudo password, and that's the case this bug can't reach. I added a second user, cloud-user, with NOPASSWD: ALL and no ansible_become_pass set, and ran the same unpatched ansible-core 2.17.6 against it three times:
run 1: 1.98s, exit code 0 run 2: 1.76s, exit code 0 run 3: 1.73s, exit code 0 No password prompt is ever generated, so there's nothing for the mismatch to break. If your playbooks only touch hosts with passwordless sudo, this bug doesn't reach you at all; it only bites once become_pass is actually set, which in my case means any host where I deliberately locked sudo down behind a password.
The documented workaround, tested
The report's other suggestion was to keep the traditional sudo binary around under its side-by-side name and point Ansible at it with ansible_become_exe=sudo.ws, instead of upgrading anything. I installed the regular sudo package alongside sudo-rs (Ubuntu's packaging keeps both, with update-alternatives choosing which one answers to /usr/bin/sudo), and reran the unpatched 2.17.6 with ansible_become_exe=sudo.ws set for that host:
run 1: 1.96s, exit code 0 run 2: 1.84s, exit code 0 run 3: 1.90s, exit code 0 It works, and it's roughly as fast as the fixed version. It needs the sudo package actually installed next to sudo-rs, though, which a minimal image (including the official Docker one I started from) doesn't have by default.
What it costs once you have more than one host
A single stuck host costs about 13 seconds. I wanted to know whether that's the whole bill or just the entry fee. Against three affected containers with Ansible's default of 5 forks, three repeated runs landed at 13.2s, 12.8s and 12.8s: the whole play fails in about the same time as a single host, because the per-host timers run in parallel and a batch that fits inside your fork count pays the cost once. With --forks 1, forcing it serial, the same three hosts took 37.0s, 37.1s and 37.0s across three runs, almost exactly three times the single-host cost, because each timeout now blocks the next connection instead of overlapping it. For anyone running a serial rolling deploy or --forks 1 for safety against a fleet of affected hosts, the 12-second figure quoted everywhere is per batch, not per run.
What I got wrong on the way
My first attempt at testing three hosts gave a play recap with one line, 127.0.0.1, where I'd expected three. I'd written the inventory with 127.0.0.1:2222, 127.0.0.1:2223 and 127.0.0.1:2224 as the hostnames, on the assumption that the port after the colon would just become ansible_port. What I'd actually done was declare the same host, 127.0.0.1, three times with three different variable sets, and Ansible's inventory parser kept only the last one. It never ran against three hosts at all; it ran once, against whichever port I'd listed last. Naming the hosts target1, target2 and target3, with ansible_host set separately on each line, was what actually got three distinct connections going.
Run it yourself
# target container cat > Dockerfile <<'EOF' FROM ubuntu:26.04 RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \ openssh-server sudo-rs python3 && mkdir -p /run/sshd RUN useradd -m -s /bin/bash deploy && echo 'deploy:deploypass' | chpasswd RUN echo 'deploy ALL=(ALL:ALL) ALL' > /etc/sudoers.d/deploy && chmod 440 /etc/sudoers.d/deploy RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] EOF docker build -t ansible-sudo-rs-test . && docker run -d -p 2222:22 ansible-sudo-rs-test # inventory.ini cat > inventory.ini <<'EOF' [target] 127.0.0.1 ansible_port=2222 ansible_user=deploy ansible_ssh_pass=deploypass ansible_become_pass=deploypass ansible_python_interpreter=/usr/bin/python3 EOF # test.yml cat > test.yml <<'EOF' - hosts: target become: yes tasks: - command: whoami register: out - debug: { var: out.stdout } EOF python3 -m venv venv-old && venv-old/bin/pip install ansible-core==2.17.6 venv-old/bin/ansible-playbook -i inventory.ini test.yml # hangs 12s, fails Where I land on this
I'd pin ansible-core to something from the 2.20 line or newer on any control node that talks to Ubuntu 26.04 with password-based sudo. I wouldn't trust a patch release of 2.16, 2.18 or 2.19 to pick the fix up quietly, because right now none of them have it, and I only found that out by actually installing each one and watching it fail the same way. Where bumping the control node's Python isn't realistic yet, ansible_become_exe=sudo.ws got me to a working playbook in under two seconds, but somebody still has to go and apt-get install sudo on the target first, because the image I started from doesn't carry it. Before doing any of that, though, I'd check what the account Ansible logs in as actually needs: mine only broke once I gave it a password to type.

