From 85d11a39e81049f702ca908ebec7c1054042d1f3 Mon Sep 17 00:00:00 2001 From: george georgovassilis Date: Tue, 1 Nov 2022 09:08:51 +0000 Subject: [PATCH] refactoring and ignoring ssh key --- .gitignore | 1 + setup-elastic-cluster.sh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8795212 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +sshkey.private diff --git a/setup-elastic-cluster.sh b/setup-elastic-cluster.sh index 60835c6..2425c91 100755 --- a/setup-elastic-cluster.sh +++ b/setup-elastic-cluster.sh @@ -1,8 +1,17 @@ #!/bin/bash -base="/home/george/Desktop/elastic" + +PATH_TO_SSH_KEY="sshkey.private" +SSH_USER="root" + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +BASE=$(dirname "$SCRIPT") + +cd "$BASE" function ans() { -ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook --inventory-file "$base/hosts" --private-key "$base/sshkey.private" -u root "$@" +ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook --inventory-file "hosts" --private-key "$PATH_TO_SSH_KEY" -u SSH_USER "$@" } ans setup-k3s-ansible/common.playbook