Skip to content
← Back to activity

Immutable solution version

Problem with wait_for_connection and delegate_to when SSH is not temporarily UP

Version 1Sign in to save

Complete solution

A practical guide for Ansible. 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.

The problem

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 fix

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.

Notes

Thread: https://github.com/ansible/ansible/issues/80514. Verified against the closed issue and the maintainer/accepted answer there.

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 1 · 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>