From d505607b1ff9d0f47b1b84c0e8491e04a8ba7310 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 11 Nov 2024 16:44:25 -0500 Subject: [PATCH] Fix remove_hosts() function 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(-) diff --git a/playbooks/roles/update_ssh_config_vagrant/update_ssh_config/update_ssh_config.py b/playbooks/roles/update_ssh_config_vagrant/update_ssh_config/update_ssh_config.py index feac31d22..731533d3c 100755 --- a/playbooks/roles/update_ssh_config_vagrant/update_ssh_config/update_ssh_config.py +++ b/playbooks/roles/update_ssh_config_vagrant/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: