From 3b5446324b74da5f2892126b75c86cf36572712b Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 21 Mar 2020 20:54:44 +0100 Subject: [PATCH] main: make key input required --- main.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.sh b/main.sh index a14c879..e911c8c 100755 --- a/main.sh +++ b/main.sh @@ -11,16 +11,20 @@ if test -z "$playbook"; then exit 1 fi -if test -n "$key"; then - mkdir -p ~/.ssh - echo "$key" > ~/.ssh/id_rsa - chmod 400 ~/.ssh/id_rsa +if test -z "$key"; then + echo "You need to specify 'key' input (SSH private key)" + exit 1 fi +mkdir -p "$HOME/.ssh" +echo "$key" > "$HOME/.ssh/id_rsa" +chmod 600 "$HOME/.ssh/id_rsa" + echo "$options" echo "$playbook" export ANSIBLE_HOST_KEY_CHECKING=False export ANSIBLE_FORCE_COLOR=True +export ANSIBLE_PRIVATE_KEY_FILE="$HOME/.ssh/id_rsa" ansible-playbook $options $playbook \ No newline at end of file