diff options
Diffstat (limited to 'common/utils.sh')
-rw-r--r-- | common/utils.sh | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/common/utils.sh b/common/utils.sh index 5199c3b6..d6795d21 100644 --- a/common/utils.sh +++ b/common/utils.sh @@ -41,13 +41,13 @@ ansible_variable__get() { ## remove ssh known_hosts entries remove_known_hosts() { - inventory_hostname="$1" - ssh_hostname=$(ssh -G "$inventory_hostname" | grep "^hostname " | awk '{ print($2) }' ) - ssh_port=$(ssh -G "$inventory_hostname" | grep "^port " | awk '{ print($2) }' ) - known_hosts_file=$(ssh -G "$inventory_hostname" | grep "^userknownhostsfile " | awk '{ print($2) }' ) - known_hosts_file=${known_hosts_file/#\~/$HOME} + local inventory_hostname="$1" + local ssh_hostname=$(ssh -G "$inventory_hostname" | grep "^hostname " | awk '{ print($2) }' ) + local ssh_port=$(ssh -G "$inventory_hostname" | grep "^port " | awk '{ print($2) }' ) + local known_hosts_file=$(ssh -G "$inventory_hostname" | grep "^userknownhostsfile " | awk '{ print($2) }' ) + local known_hosts_file=${known_hosts_file/#\~/$HOME} - declare -a names + local -a names names+=("$inventory_hostname") names+=("$ssh_hostname") names+=("$ssh_hostname:$ssh_port") @@ -59,6 +59,7 @@ remove_known_hosts() { names+=("$host_name") ansible_variable__get host_domain "$inventory_hostname" > /dev/null 2>&1 && names+=("$host_name.$host_domain") + local name="" for name in ${names[@]} ; do ssh-keygen -f "$known_hosts_file" -R "$name" done |