diff --git a/scripts/hosts b/scripts/hosts index 2c725ee..9ee1eed 100644 --- a/scripts/hosts +++ b/scripts/hosts @@ -1,3 +1 @@ -us-mc02-prod-mp-ub2204-en0-microk8s-0 -us-mc02-prod-mp-ub2204-en0-microk8s-1 -us-mc02-prod-mp-ub2204-en0-microk8s-2 +us-mc02-prod-utm-ub2204-microk8s-0 diff --git a/scripts/multipassInstallPreRequired.sh b/scripts/multipassInstallPreRequired.sh index 7a3098c..b837261 100644 --- a/scripts/multipassInstallPreRequired.sh +++ b/scripts/multipassInstallPreRequired.sh @@ -1,3 +1,33 @@ +function multipassExecTaskV1 +{ + host=$1 + echo $host + + machine="localhost" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + $executor sudo apt update -y + $executor sudo apt install ansible -y + $executor mkdir repo + $executor git config --global user.email "agalyadoss@gmail.com" + $executor git config --global user.name "Agalya Ramadoss" + $executor sudo addgroup --gid 8055 boss + $executor sudo adduser --system --shell /bin/bash --uid 805501 --gid 8055 aboss + $executor sudo adduser --system --shell /bin/bash --uid 905501 --gid 8055 adoss + $executor sudo usermod -aG sudo aboss + $executor sudo usermod -aG sudo adoss + $executor sudo sh -c "echo aboss:$root_password|sudo chpasswd" + $executor sudo sh -c "echo adoss:$root_password|sudo chpasswd" + $executor sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config + $executor sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config + $executor sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin enabled/" /etc/ssh/sshd_config + $executor sudo sh -c "ssh-keygen -N '' -q -f ~/.ssh/id_rsa -t rsa -b 4096 -C root" + + + +} function multipassExecTask1 { host=$1 @@ -29,8 +59,7 @@ } - -function multipassExecPostTask +function multipassExecPostTask { host=$1 echo $host @@ -44,6 +73,43 @@ done } + +function multipassExecPostTaskV1 +{ + host=$1 + echo $host + machine="localhost" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + id_rsa=`$executor sudo cat /root/.ssh/id_rsa.pub` + for chost in `cat hosts` + do + echo $chost + $executor sudo sh -c "echo '$id_rsa'>> /root/.ssh/authorized_keys" + echo "sleeping for 1 seconds copy from $host to $chost " + sleep 1 + done + +} +function multipassExecSshVerifyV1 +{ + host=$1 + echo $host + machine="localhost" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + for chost in `cat hosts` + do + echo $chost + $executor sudo sh -c "ssh-keyscan $host >> /root/.ssh/known_hosts" + #multipass exec $chost -- sudo ssh $host + #ssh-keyscan us-mc02-pac-mp-ub2204-en0-kubeadm-2 >> $HOME/.ssh/known_hosts + done +} function multipassExecSshVerify { host=$1 @@ -65,13 +131,14 @@ for host in `cat hosts` do - multipassExecTask1 $host +# multipassExecTaskV1 $host + echo $host done for host in `cat hosts` do - multipassExecPostTask $host + multipassExecPostTaskV1 $host done for host in `cat hosts` do - multipassExecSshVerify $host + multipassExecSshVerifyV1 $host done