From d9254aac36bb368ba2094b54b35e41b4cf525e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Wed, 5 Jun 2024 23:24:34 +0300 Subject: [PATCH] Code Update --- init.sh | 14 +++++++------- src/functions/init.sh | 6 +++--- src/functions/stop.sh | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/init.sh b/init.sh index d0df228..08f1c66 100755 --- a/init.sh +++ b/init.sh @@ -17,7 +17,7 @@ wiBold=$(tput bold) wiNormal=$(tput sgr0) wi-header(){ - wx-header "$1" $2 + wx-header "$1" "$2" } wi-repeat(){ @@ -68,7 +68,7 @@ wi-init(){ wi-login $1 $2 wi-header "Init" - mkdir -p ~/.ssh &> /dev/null + mkdir -p ~/.ssh/keys &> /dev/null apt-get install -y python3-pip python3-venv jq git curl &> /dev/null python3 -m venv /opt/ansible &> /dev/null @@ -79,9 +79,9 @@ wi-init(){ -X GET \ https://$VAULT_DOMAIN/v1/init.sh/data/ssh -s | jq -r '.data.data.privkey' > ~/.ssh/init - chmod 700 ~/.ssh/init + chmod 700 ~/.ssh/keys/init &> /dev/null - mkdir -p ~/.ansible > /dev/null + mkdir -p ~/.ansible &> /dev/null if [ ! -f ~/.ansible/vars.yml ] then @@ -105,13 +105,11 @@ wi-init(){ GIT_PORT="2222" GIT_REPOSITORY="warengroup-private/infra-plus" - ssh-keyscan -p $GIT_PORT $GIT_DOMAIN &> ~/.ssh/known_hosts - export HVT=${config["login",$ORG]} /opt/ansible/bin/ansible-galaxy collection install ansible.posix ansible.utils community.crypto community.docker community.general community.hashi_vault community.libvirt community.mysql community.postgresql containers.podman --upgrade &> /dev/null - /opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY --vault-password-file ~/.ansible/vault.yml --private-key ~/.ssh/init playbooks/init.yml -t init + /opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY --accept-host-key --vault-password-file ~/.ansible/vault.yml --private-key ~/.ssh/init playbooks/init.yml -t init unset HVT } @@ -311,6 +309,8 @@ wi-stop (){ echo " " echo " " + rm -rf /.ssh/keys/init &> /dev/null + exit 1 } diff --git a/src/functions/init.sh b/src/functions/init.sh index 827c12e..41d26bd 100644 --- a/src/functions/init.sh +++ b/src/functions/init.sh @@ -2,7 +2,7 @@ wi-init(){ wi-login $1 $2 wi-header "Init" - mkdir -p ~/.ssh &> /dev/null + mkdir -p ~/.ssh/keys &> /dev/null apt-get install -y python3-pip python3-venv jq git curl &> /dev/null python3 -m venv /opt/ansible &> /dev/null @@ -13,9 +13,9 @@ wi-init(){ -X GET \ https://$VAULT_DOMAIN/v1/init.sh/data/ssh -s | jq -r '.data.data.privkey' > ~/.ssh/init - chmod 700 ~/.ssh/init + chmod 700 ~/.ssh/keys/init &> /dev/null - mkdir -p ~/.ansible > /dev/null + mkdir -p ~/.ansible &> /dev/null if [ ! -f ~/.ansible/vars.yml ] then diff --git a/src/functions/stop.sh b/src/functions/stop.sh index e449482..d43bf70 100644 --- a/src/functions/stop.sh +++ b/src/functions/stop.sh @@ -3,5 +3,7 @@ wi-stop (){ echo " " echo " " + rm -rf /.ssh/keys/init &> /dev/null + exit 1 }