diff --git a/scripts/createVm.sh b/scripts/createVm.sh index 16c9e72..a63947c 100644 --- a/scripts/createVm.sh +++ b/scripts/createVm.sh @@ -10,6 +10,7 @@ function findEthEthernet { + set -x eth0=`multipass networks |grep ethernet | grep -v Adapter |cut -d " " -f1` if [ "$eth0" == "" ] @@ -29,9 +30,10 @@ function createVm { + set -x action=$1 - NETWORK=`findEthEthernet` + NETWORK=$2 if [ "Shanthys-Mini.heaerieglobalsolutions.net" == "$currentHost" ] then @@ -79,10 +81,11 @@ fi +NETWORK=`findEthEthernet` for i in $(seq 1 $noOfinstance) do echo "$i" - createVm $action + createVm $action $NETWORK done diff --git a/scripts/hosts b/scripts/hosts index ea84146..6df1ece 100644 --- a/scripts/hosts +++ b/scripts/hosts @@ -1,4 +1,4 @@ +us-mc02-mp-ub2204-en0-kubeadm-0 us-mc02-mp-ub2204-en0-kubeadm-1 us-mc02-mp-ub2204-en0-kubeadm-2 us-mc02-mp-ub2204-en0-kubeadm-3 -us-mc02-mp-ub2204-en0-kubeadm-4 diff --git a/scripts/multipassInstallPreRequired.sh b/scripts/multipassInstallPreRequired.sh index c873432..ad33712 100644 --- a/scripts/multipassInstallPreRequired.sh +++ b/scripts/multipassInstallPreRequired.sh @@ -1,4 +1,4 @@ -function multipassExec +function multipassExecTask1 { host=$1 echo $host @@ -16,8 +16,6 @@ multipass exec $host -- sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config multipass exec $host -- sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin enabled/" /etc/ssh/sshd_config multipass exec $host -- sudo ssh-keygen -t rsa -b 4096 -C "root" - id_rsa=`multipass exec us-mc02-mp-ub2204-en0-kubeadm-0 -- sudo cat /root/.ssh/id_rsa.pub` - multipass exec $host -- sudo sh -c "echo '$id_rsa'>> /root/.ssh/authorized_keys" # multipass exec $host -- sudo vim /etc/ssh/sshd_config # multipass exec $host -- sudo passwd # multipass exec $host -- sudo vim /root/.ssh/authorized_keys @@ -27,8 +25,23 @@ } +function multipassExecPostTask +{ + host=$1 + echo $host + for chost in `cat hosts` + do + id_rsa=`multipass exec $chost -- sudo cat /root/.ssh/id_rsa.pub` + multipass exec $host -- sudo sh -c "echo '$id_rsa'>> /root/.ssh/authorized_keys" + done + +} for host in `cat hosts` do - multipassExec $host + multipassExecTask1 $host +done +for host in `cat hosts` +do + multipassExecPostTask $host done