From patchwork Mon Nov 11 21:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13871428 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2AA791BC06E for ; Mon, 11 Nov 2024 21:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731361469; cv=none; b=J1GdeavJnXNPYFd6In2ZNy2A7BP390fQ37fFODWPOKnG103RQHns46JdtADmca9n11y3MyvOmMijlItJ/XijhIb1yHlLQyUffbYmlQJ8cyq6OFWbY8wvfBt+bOPuSPu7Z59I6wyqLn1Esk0H9x1Yoar2KlNaJ0IhWSMW8Xj1X6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731361469; c=relaxed/simple; bh=Mi5tHdEGjdV/2qBx+1jszVYkUANxG428yto2uiFRf8g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YGRpVnvQJh+XTH1MWuewnY/zS+Xdfl77gx4G3AiPGlI4OnpOtrT1cPOL9UZCj+mfenegg/iyjt+kvtv7yyQnw87jsYsq+vJFgsuCXVzLn3KVxf9aBatQgGN+LjmEFbVHnR6Upy4Ajft5pT5LdCyMVrT+DyrQX52W3RFJn5gs7HA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zaa0DUIr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zaa0DUIr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3909DC4CED4; Mon, 11 Nov 2024 21:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731361468; bh=Mi5tHdEGjdV/2qBx+1jszVYkUANxG428yto2uiFRf8g=; h=From:To:Cc:Subject:Date:From; b=Zaa0DUIrJAwlK9V7K2EmaoAkwc7Fl9NCV61l91IzWl/M7Dg/S4ZxeO53+ConbyCSo qVShzLXVFhreSvPs5tu2LsttcCFpWZXsqaaQZW7sT8FjpLGmaDMjZ0ce1xBYgzzD/l kOIMZRvOL9ly0Lq0mAcZ5kmzMnfyc47XAPseEDor4uyhzcn38XJ11i/Xc8c23y5j8Z 19uIEQzkA/GNtZceQaL7w27cw8p/FwVpJAwKp1eajwG8P5MBk2uUNGw/s+xu6ZfbO5 y70Tzg9kyG9YT8WmzzGXFFatmROMzDPw8/Eb/SfTwgkRJrcsZawUlwHLaWR2PdaBDp 3G9FHNWWiKHBw== From: cel@kernel.org To: Luis Chamberlain Cc: , Chuck Lever Subject: [PATCH] Fix remove_hosts() function Date: Mon, 11 Nov 2024 16:44:25 -0500 Message-ID: <20241111214425.712423-1-cel@kernel.org> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever Commit 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host line") added an IP address at the end of each Host line. This extra field breaks the simple host entry matching logic in the remove_hosts() function, making "--remove" a no-op. If the ssh_config entries are not removed, the config file grows without bounds. If new hostnames are added that have the same name as existing entries, ssh to those hosts fails, which makes certain Ansible tasks hang for a bit and then fail. Fixes: 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host line") Signed-off-by: Chuck Lever --- update_ssh_config/update_ssh_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) This is the simple patch that address the immediate concern about "--remove" not working. I can push it directly to the github repo, or I can open a github PR, or you can apply it. Let me know. diff --git a/update_ssh_config/update_ssh_config.py b/update_ssh_config/update_ssh_config.py index feac31d2272f..731533d3cc76 100755 --- a/update_ssh_config/update_ssh_config.py +++ b/update_ssh_config/update_ssh_config.py @@ -41,7 +41,7 @@ def remove_hosts(args): if len(kv) > 1: key, value = kv if key.lower() == "host": - if value in hosts: + if value.split(' ')[0] in hosts: rm_this_host = True continue else: