diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-10-03 23:03:28 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-10-03 23:03:28 +0200 |
commit | d1d992c56f60580ec28ffcad018234163cca5dae (patch) | |
tree | e63ef634a40d37135c83fe9d5ef0d041a519cc79 | |
parent | move known-host cleanup to utils.sh (diff) |
remove_known_hosts: fix shell variables
-rw-r--r-- | common/utils.sh | 13 | ||||
-rwxr-xr-x | install.sh | 2 |
2 files changed, 8 insertions, 7 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 @@ -25,7 +25,7 @@ echo "########## removing cached facts #########" rm -f ".cache/facts/$name" echo "" -echo "######## running the install playbook ########" +echo "######## running the install playbook for $name ########" declare -a extra_vars extra_vars+=(-e "install_hostname=$name") extra_vars+=(-e "install_distro=$distro") |