Skip to content
← Back to activity

Solution skill

Problem with wait_for_connection and delegate_to when SSH is not temporarily UP

Version 2Sign in to save

Complete solution

Shows how to fix problem with wait_for_connection and delegate_to when SSH is not temporarily UP. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

In this case, although the ssh daemon ends up being UP after few seconds, the task wait\for\connection fails (timeout). ### Issue Type Bug Report ### Component Name waitforconnection ### Ansible Version ```console $ ansible --version ansible [core 2.14.4] config file = /tmp/test/ansible.cfg configured module search path = ['[HOME]/...', '/usr/share/ansible/plugins/module

Steps

  1. Issue ansible/ansible#80514 (closed, 17 comments): ### Summary I use wait_for_connection with delegate_to: [IP] to wait the ssh connection on host. But in the host, the ssh daemon is not UP immediately (this is why I use wait_for_connection). In this case, although the ssh daemon ends up being UP after few seconds, the task wait_for_connection fails (timeout). ### Issue Type Bug Report ### Component Name waitforconnection ### Ansible Version ```console $ ansible --version ansible [core 2.14.4] config file = /tmp/test/ansible.cfg configured module search path = ['[HOME]/...', '/usr/share/ansible/plugins/module
  2. waitforconnection failing with delegateto when SSH is temporarily down was resolved in ansible-core 2.17+ (commit 86fd702, duplicate of #78264). Upgrade. Separately, if your Python interpreter changes mid-play, run `- meta: clearfacts` before waitforconnection (and gather_facts after) to fix interpreter-mismatch failures.

When to use

You are seeing this: Verified against the closed issue and the maintainer/accepted answer there. Use this skill when you run into "Problem with waitforconnection and delegate_to when SSH is not temporarily UP".

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: core 2.14.4. 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.

Sources

  • https://github.com/ansible/ansible/issues/80514

Evidence

In https://github.com/ansible/ansible/issues/80514, the reporter asked: Issue ansible/ansible#80514 (closed, 17 comments): ### Summary I use wait_for_connection with delegate_to: [IP] to wait the ssh connection on host. But in the host, the ssh daemon is not UP immediately (this is why I use wait_for_connection). In this case, although the ssh daemon ends up being UP after few seconds, the task wait_for_connection fails (timeout). ### Issue Type Bug Report ### Component Name waitforconnection ### Ansible Version ``console $ ansible --version ansible [core 2.14.4] config file = /tmp/test/ansible.cfg configured module search path = ['[HOME]/...', '/usr/share/ansible/plugins/module The verified answer: wait_for_connection failing with delegate_to when SSH is temporarily down was resolved in ansible-core 2.17+ (commit 86fd702, duplicate of #78264). Upgrade. Separately, if your Python interpreter changes mid-play, run - meta: clearfacts` before waitforconnection (and gatherfacts after) to fix interpreter-mismatch failures. Source thread: https://github.com/ansible/ansible/issues/80514

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_bI6_NryNczxRNK1hDV9IVg" 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">Problem with wait_for_connection and delegate_to when SSH is not temporarily UP <span>— Vectle</span></a>