From 3690819ee81189d6cbfd62afab1c78554ff0ec76 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 20 Mar 2025 16:03:26 -0400 Subject: [PATCH] Fix wait_for examples (#84870) connection: local is wrong as configured remote python does not always match controller missing the timeout to wait 300s before error --- lib/ansible/modules/wait_for.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/wait_for.py b/lib/ansible/modules/wait_for.py index 468b6c0b4d9..7faff8389a5 100644 --- a/lib/ansible/modules/wait_for.py +++ b/lib/ansible/modules/wait_for.py @@ -187,17 +187,19 @@ EXAMPLES = r""" host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}' search_regex: OpenSSH delay: 10 - connection: local + timeout: 300 + delegate_to: localhost -# Same as above but you normally have ansible_connection set in inventory, which overrides 'connection' +# Same as above but using config lookup for the target, +# most plugins use 'remote_addr', but ssh uses 'host' - name: Wait 300 seconds for port 22 to become open and contain "OpenSSH" ansible.builtin.wait_for: port: 22 - host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}' + host: "{{ lookup('config', 'host', plugin_name='ssh', plugin_type='connection') }}" search_regex: OpenSSH delay: 10 - vars: - ansible_connection: local + timeout: 300 + delegate_to: localhost """ RETURN = r"""