From ee1ffbdb21ab442e5bd997ae14748975c7a19b3e Mon Sep 17 00:00:00 2001 From: downtownallday Date: Sat, 9 Apr 2022 18:55:11 -0400 Subject: [PATCH] Workaround vagrant's inability to authenticate during vagrant up (but can authenticate with vagrant ssh) --- tests/vagrant/preloaded/Vagrantfile | 1 + tests/vagrant/preloaded/create_preloaded.sh | 27 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/vagrant/preloaded/Vagrantfile b/tests/vagrant/preloaded/Vagrantfile index ee9d60c4..62d31053 100644 --- a/tests/vagrant/preloaded/Vagrantfile +++ b/tests/vagrant/preloaded/Vagrantfile @@ -30,6 +30,7 @@ SH config.vm.define "preloaded-ubuntu-jammy64" do |m1| m1.vm.box = "ubuntu/jammy64" + m1.vm.boot_timeout = 30 m1.vm.provision :shell, :inline => <<-SH cd /mailinabox tests/vagrant/preloaded/prepvm.sh --no-dry-run diff --git a/tests/vagrant/preloaded/create_preloaded.sh b/tests/vagrant/preloaded/create_preloaded.sh index dccf8fe3..3292417a 100755 --- a/tests/vagrant/preloaded/create_preloaded.sh +++ b/tests/vagrant/preloaded/create_preloaded.sh @@ -45,10 +45,26 @@ do fi export RELEASE_TAG="${tags[$idx]}" - vagrant up $box + vagrant up $box | tee /tmp/$box.out upcode=$? + + if [ $upcode -eq 0 -a ! -e "./prepcode.txt" ] && ${try_reboot[$idx]} && grep -F 'Authentication failure' /tmp/$box.out >/dev/null; then + # note: upcode is 0 only if config.vm.boot_timeout is set. + # If this works it may be an indication that ruby's internal + # ssh does not support the algorithm required by the server, + # or the public key does not match (vagrant and vm out of + # sync) + echo "" + echo "VAGRANT AUTHENTICATION FAILURE - TRYING LOOSER ALLOWED SSHD ALGS" + if vagrant ssh $box -c "sudo bash -c 'echo PubkeyAcceptedAlgorithms +ssh-rsa > /etc/ssh/sshd_config.d/miabldap.conf; sudo systemctl restart sshd'"; then + vagrant halt $box + vagrant up $box + upcode=$? + fi + fi + if [ $upcode -ne 0 -a ! -e "./prepcode.txt" ] && ${try_reboot[$idx]} - then + then # a reboot may be necessary if guest addtions was newly # compiled by vagrant plugin "vagrant-vbguest" echo "" @@ -57,6 +73,8 @@ do vagrant up $box upcode=$? fi + + rm -f /tmp/$box.out let idx+=1 prepcode=$(cat "./prepcode.txt") @@ -71,8 +89,11 @@ do exit 1 fi - if vagrant ssh $box -- cat /var/run/reboot-required; then + if vagrant ssh $box -- cat /var/run/reboot-required >/dev/null 2>&1; then + echo "REBOOT REQUIRED" vagrant reload $box + else + echo "REBOOT NOT REQUIRED" fi vagrant halt $box