From c6a391c8d8ce357623f8eb2eb9d7c77d1f36f701 Mon Sep 17 00:00:00 2001 From: Matt Davis <6775756+nitzmahone@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:54:08 -0700 Subject: [PATCH] fix delegate_to integration test (#83865) * the test was previously passing erroneously due to the `timeout` elapsing in CI, and that the `failed` test does not encompass `unreachable` --- .../delegate_with_fact_from_delegate_host.yml | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/test/integration/targets/delegate_to/delegate_with_fact_from_delegate_host.yml b/test/integration/targets/delegate_to/delegate_with_fact_from_delegate_host.yml index 16703984232..97b0d7d08c8 100644 --- a/test/integration/targets/delegate_to/delegate_with_fact_from_delegate_host.yml +++ b/test/integration/targets/delegate_to/delegate_with_fact_from_delegate_host.yml @@ -1,18 +1,37 @@ -- name: ensure we can use fact on delegated host for connection info +- name: create a dedicated broken host and a working copy of localhost to delegate to hosts: localhost gather_facts: no tasks: - - add_host: name=f31 bogus_user=notme ansible_connection=ssh ansible_host=4.2.2.2 + - add_host: + name: busted + ansible_connection: ssh + ansible_host: localhost + ansible_port: 1 + - add_host: + name: delegate_to_local + ansible_connection: local + ansible_python_interpreter: '{{ ansible_playbook_python }}' - - name: if not overriding with delegated host info, will not be unreachable +- name: play targets an unreachable host, delegates to a working one + hosts: busted + gather_facts: no + tasks: + - name: attempt to connect to a broken host ping: - timeout: 5 - delegate_to: f31 + timeout: 5 # backstop for a tarpit port or dropped packets ignore_errors: true ignore_unreachable: true - register: delping + register: broken_ping + - assert: + that: + - broken_ping is unreachable + + - name: delegate to the valid host + ping: + delegate_to: delegate_to_local + register: delegated_ping - - name: ensure that the expected happened - assert: + - assert: that: - - delping is failed + - delegated_ping is success + - delegated_ping is reachable