From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3F892E284D for ; Mon, 11 Aug 2025 22:24:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754951097; cv=none; b=n4/n0HU1HGgpRKCe8hXcvExloUDuO+jKuJzRfmqRs+ZX992/2z4moPzGP3n1XY5VaqOg1Q0n0V7+QIrbA4UEVKsfTdeFFA7CthyePKyxt3DXNdY9eEnM/brCyWHB8qg4t1vu2L5ROksAl6eV1LAi+os4D6Q12XGDIRPLl6dESgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754951097; c=relaxed/simple; bh=J7xgsqOU3Jn4wKSQsIyMY5SnTH3DdD4BypDbu85rrj8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IGf76SJ9d0r/cI5hw+rfZ+ayd+kM9v75oKMjf3250Hn9EiYw1jfdV54/7ksI2QdTpOd1/dYcMKMy+db6gi6chHnmjLdOJSI4Cuv3cV1p6O8toqHJ2os3hIr5Ot9kUNwM8X4hIbAtOs+bwcNIbgo73v/wGFnOnIF/f7Ep7wzmMG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=euGA+GKl; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="euGA+GKl" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Cmggr/W+1vSMsnoAEeT1ibrC4ikDfY46YFZas4WtYQI=; b=euGA+GKltV5qcDA4Vh0TJHTsnX u4yOfPbOnXYB2R2X7pdE57kWobiclCbD9C2qRHyILN++8FZ36BxavlGxXM5RgWe2juJIiV6pa5qV+ z2a3Nh/aRrT4fqOU2XV0RD/nEslTbtM1Df5yiSdGEdVmTxbfBijB9r4El/HkZW9ngzPieJNYQTops Q9X5qMspkyGrPx1wzXHus3/9rFKvSIiiWkIAqhNJqRi9I6oBUolpzAdUHM4aMj5UEweqzJnnoP/Is 8qapSHHV8fC1Fn261g30U3orT40Fg45YxCsUALGqruux5cItGwKdpsogS4GWX9lr95ENvJMcmj96t 04Q5Xl7Q==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ulawn-00000009HkY-3klU; Mon, 11 Aug 2025 22:24:53 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 20/23] reboot-limit: use ansible reboot module for all reboot types Date: Mon, 11 Aug 2025 15:24:47 -0700 Message-ID: <20250811222452.2213071-21-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250811222452.2213071-1-mcgrof@kernel.org> References: <20250811222452.2213071-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Replace the complex async command execution and wait_for logic with the ansible reboot module, which properly handles SSH connections during system reboots. The reboot module: - Supports custom reboot commands via reboot_command parameter - Handles connection loss and recovery automatically - Works correctly with kdevops SSH configuration - Avoids the localhost host resolution issues with wait_for This simplifies the code and makes all three reboot methods (ansible, systemctl reboot, systemctl kexec) use the same robust reboot handling mechanism. Generated-by: Claude AI Signed-off-by: Luis Chamberlain --- .../roles/reboot-limit/tasks/do-reboot.yml | 68 ++++--------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/playbooks/roles/reboot-limit/tasks/do-reboot.yml b/playbooks/roles/reboot-limit/tasks/do-reboot.yml index 955f80be..ec2c29df 100644 --- a/playbooks/roles/reboot-limit/tasks/do-reboot.yml +++ b/playbooks/roles/reboot-limit/tasks/do-reboot.yml @@ -17,36 +17,14 @@ - reboot_limit_test_type == "ansible" tags: [ 'run_tests' ] -- name: Run the reboot test using systemctl reboot +- name: Reboot using systemctl reboot with proper handling become: yes become_method: sudo - command: "systemctl reboot" - async: 1 - poll: 0 - when: - - reboot_limit_test_type == "systemctl_reboot" - tags: [ 'run_tests' ] - -- name: Wait for system to go down for reboot - wait_for: - host: "{{ ansible_ssh_host | default(ansible_host) | default(inventory_hostname) }}" - port: 22 - state: stopped - delay: 5 - timeout: 60 - delegate_to: localhost - when: - - reboot_limit_test_type == "systemctl_reboot" - tags: [ 'run_tests' ] - -- name: Wait for system to come back after reboot - wait_for: - host: "{{ ansible_ssh_host | default(ansible_host) | default(inventory_hostname) }}" - port: 22 - state: started - delay: 10 - timeout: 300 - delegate_to: localhost + reboot: + msg: "Rebooting system via systemctl reboot for reboot-limit test" + reboot_command: "systemctl reboot" + post_reboot_delay: 10 + reboot_timeout: 300 when: - reboot_limit_test_type == "systemctl_reboot" tags: [ 'run_tests' ] @@ -125,36 +103,14 @@ - kexec_initrd_path is defined tags: [ 'run_tests' ] -- name: Run the reboot test using systemctl kexec +- name: Reboot using systemctl kexec with proper handling become: yes become_method: sudo - command: "systemctl kexec" - async: 1 - poll: 0 - when: - - reboot_limit_test_type == "systemctl_kexec" - tags: [ 'run_tests' ] - -- name: Wait for system to go down for kexec - wait_for: - host: "{{ ansible_ssh_host | default(ansible_host) | default(inventory_hostname) }}" - port: 22 - state: stopped - delay: 5 - timeout: 60 - delegate_to: localhost - when: - - reboot_limit_test_type == "systemctl_kexec" - tags: [ 'run_tests' ] - -- name: Wait for system to come back after kexec - wait_for: - host: "{{ ansible_ssh_host | default(ansible_host) | default(inventory_hostname) }}" - port: 22 - state: started - delay: 10 - timeout: 300 - delegate_to: localhost + reboot: + msg: "Rebooting system via systemctl kexec for reboot-limit test" + reboot_command: "systemctl kexec" + post_reboot_delay: 10 + reboot_timeout: 300 when: - reboot_limit_test_type == "systemctl_kexec" tags: [ 'run_tests' ] -- 2.47.2