From 061c504e9879fbfb9fd1ba9f9e67bc068fe262ef Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 20 Oct 2025 16:55:12 +0200 Subject: [PATCH] [stable-2.20] Avoid the ssh-agent exiting before tests end (#85979) (#86008) There were couple of occurrences where the hard 30 seconds limit on running ssh-agent was not enough for the test to run and the ssh-agent was killed resulting in the test failing with "Connection refused". This change just lets the agent run in the background and kills it manually after the tests finish. (cherry picked from commit 05d5b0f168513922166a7f2190695a1acd0f1b33) --- .../targets/ssh_agent/tasks/tests.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/integration/targets/ssh_agent/tasks/tests.yml b/test/integration/targets/ssh_agent/tasks/tests.yml index 9429138638c..237a8b0a526 100644 --- a/test/integration/targets/ssh_agent/tasks/tests.yml +++ b/test/integration/targets/ssh_agent/tasks/tests.yml @@ -29,15 +29,17 @@ vars: pid: '{{ auto.stdout|regex_findall("ssh-agent\[(\d+)\]")|first }}' -- command: ssh-agent -D -s -a '{{ output_dir }}/agent.sock' - async: 30 - poll: 0 +- shell: ssh-agent -D -s -a '{{ output_dir }}/agent.sock' & + register: ssh_agent_result -- command: ansible-playbook -i {{ ansible_inventory_sources|first|quote }} -vvv {{ role_path }}/auto.yml - environment: - ANSIBLE_CALLBACK_RESULT_FORMAT: yaml - ANSIBLE_SSH_AGENT: '{{ output_dir }}/agent.sock' - register: existing +- block: + - command: ansible-playbook -i {{ ansible_inventory_sources|first|quote }} -vvv {{ role_path }}/auto.yml + environment: + ANSIBLE_CALLBACK_RESULT_FORMAT: yaml + ANSIBLE_SSH_AGENT: '{{ output_dir }}/agent.sock' + register: existing + always: + - command: "kill {{ ssh_agent_result.stdout | regex_search('Agent pid ([0-9]+)', '\\1') | first }}" - assert: that: