Immutable solution version
Timeout (12s) waiting for privilege escalation prompt with become on long-running commands
Complete solution
Shows how to fix timeout (12s) waiting for privilege escalation prompt with become on long-running commands. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
What actually fixes it (verified in the thread): Ansible's default 12-second timeout for the privilege-escalation prompt is too short for hosts where ssh or sudo is slow (common causes: slow DNS resolution or an incomplete /etc/hosts making sudo hang on hostname lookup).
Steps
- Tasks using become with with_items failed with Timeout (12s) waiting for privilege escalation prompt whenever a single command took longer than 12 seconds, even though the same playbook worked against other hosts. Plain ssh to the host was fast, and the same commands ran fine without become. The failure is the become timeout, not the task itself.
- What actually fixes it (verified in the thread):
- Ansible's default 12-second timeout for the privilege-escalation prompt is too short for hosts where ssh or sudo is slow (common causes: slow DNS resolution or an incomplete /etc/hosts making sudo hang on hostname lookup). Raise the timeout in ansible.cfg by adding timeout=30 under [defaults]; several reporters confirmed this fixed the playbook. Also check that ssh connects in under a second and sudo runs fast on the target, and that /etc/hosts maps the hostname to the loopback address or 127.0.1.1, since slow name resolution is the usual root cause.
When to use
You are seeing this: The situation: Tasks using become with with_items failed with Timeout (12s) waiting for privilege escalation prompt whenever a single command took longer than 12 seconds, even though the same playbook worked against other hosts. Use this skill when you run into "Timeout (12s) waiting for privilege escalation prompt with become on long-running commands".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: 127.0.1.1. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Also check that ssh connects in under a second and sudo runs fast on the target, and that /etc/hosts maps the hostname to the loopback address or 127.0.1.1, since slow name resolution is the usual root cause.
Evidence
Someone asked: Tasks using become with withitems failed with Timeout (12s) waiting for privilege escalation prompt whenever a single command took longer than 12 seconds, even though the same playbook worked against other hosts. Plain ssh to the host was fast, and the same commands ran fine without become. The failure is the become timeout, not the task itself. The verified answer: Ansible's default 12-second timeout for the privilege-escalation prompt is too short for hosts where ssh or sudo is slow (common causes: slow DNS resolution or an incomplete /etc/hosts making sudo hang on hostname lookup). Raise the timeout in ansible.cfg by adding timeout=30 under [defaults]; several reporters confirmed this fixed the playbook. Also check that ssh connects in under a second and sudo runs fast on the target, and that /etc/hosts maps the hostname to the loopback address or 127.0.1.1, since slow name resolution is the usual root cause. Full thread: https://vectle.com/threads/thrv9VvCpaT-52pUxUgJ3SzbQ
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_deIH9tSKIeaMiCz3a3HlVA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Timeout (12s) waiting for privilege escalation prompt with become on long-running commands <span>— Vectle</span></a>