Code Update

This commit is contained in:
Christer Warén 2024-06-05 23:24:34 +03:00
parent 352b7b2325
commit d9254aac36
3 changed files with 12 additions and 10 deletions

14
init.sh
View File

@ -17,7 +17,7 @@ wiBold=$(tput bold)
wiNormal=$(tput sgr0) wiNormal=$(tput sgr0)
wi-header(){ wi-header(){
wx-header "$1" $2 wx-header "$1" "$2"
} }
wi-repeat(){ wi-repeat(){
@ -68,7 +68,7 @@ wi-init(){
wi-login $1 $2 wi-login $1 $2
wi-header "Init" 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 apt-get install -y python3-pip python3-venv jq git curl &> /dev/null
python3 -m venv /opt/ansible &> /dev/null python3 -m venv /opt/ansible &> /dev/null
@ -79,9 +79,9 @@ wi-init(){
-X GET \ -X GET \
https://$VAULT_DOMAIN/v1/init.sh/data/ssh -s | jq -r '.data.data.privkey' > ~/.ssh/init 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 ] if [ ! -f ~/.ansible/vars.yml ]
then then
@ -105,13 +105,11 @@ wi-init(){
GIT_PORT="2222" GIT_PORT="2222"
GIT_REPOSITORY="warengroup-private/infra-plus" GIT_REPOSITORY="warengroup-private/infra-plus"
ssh-keyscan -p $GIT_PORT $GIT_DOMAIN &> ~/.ssh/known_hosts
export HVT=${config["login",$ORG]} 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-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 unset HVT
} }
@ -311,6 +309,8 @@ wi-stop (){
echo " " echo " "
echo " " echo " "
rm -rf /.ssh/keys/init &> /dev/null
exit 1 exit 1
} }

View File

@ -2,7 +2,7 @@ wi-init(){
wi-login $1 $2 wi-login $1 $2
wi-header "Init" 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 apt-get install -y python3-pip python3-venv jq git curl &> /dev/null
python3 -m venv /opt/ansible &> /dev/null python3 -m venv /opt/ansible &> /dev/null
@ -13,9 +13,9 @@ wi-init(){
-X GET \ -X GET \
https://$VAULT_DOMAIN/v1/init.sh/data/ssh -s | jq -r '.data.data.privkey' > ~/.ssh/init 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 ] if [ ! -f ~/.ansible/vars.yml ]
then then

View File

@ -3,5 +3,7 @@ wi-stop (){
echo " " echo " "
echo " " echo " "
rm -rf /.ssh/keys/init &> /dev/null
exit 1 exit 1
} }