Fix remove_hosts() function
PATCH 1/1 Fix remove_hosts() function
From: Chuck Lever <[email protected]>
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.
--- 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.
update_ssh_config/update_ssh_config.py +1 -1
@@ -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:
Signature · 1 line
2.47.0
Quoted 14 lines · On Mon, Nov 11, 2024 at 04:44:25PM -0500, [email protected] wrote:
From: Chuck Lever <[email protected]>
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 theremove_hosts()function, making "--remove" a no-op.If the
ssh_configentries 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 <[email protected]>
Quoted 7 lines
--- 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.
Please just push! All patches posted to the kdevops mailing list get automatically tested now thanks to our integration with kpd [0] the results published on the kdevops-kpd tree [1].
[0] https://github.com/linux-kdevops/kdevops/blob/main/docs/kernel-ci/README.md
[1] https://github.com/linux-kdevops/kdevops-kpd/actions
Luis