Skip to content

Commit

Permalink
Switch to ed25519 keys
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Mar 20, 2023
1 parent 6d52833 commit f649304
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ansible/pbTestScripts/vagrantPlaybookCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,14 @@ startVMPlaybook()
ln -sf ${scriptPath%/*}/../vagrant/Vagrantfile.$OS Vagrantfile
fi
# Copy the machine's ssh key for the VMs to use, after removing prior files
rm -f id_rsa.pub id_rsa
ssh-keygen -q -f $PWD/id_rsa -t rsa -N ''
if [ "$OS" = "Ubuntu2204" ]; then
sshKeyType=ed25519
else
sshKeyType=rsa
fi
sshKeyFile=id_${sshKeyType}
rm -f ${sshKeyFile} ${sshKeyFile}.pub
ssh-keygen -q -f $PWD/${sshKeyFile} -t ${sshKeyType} -N ''

# The BUILD_ID variable is required to stop Jenkins shutting down the wrong VMS
# See https://github.com/adoptium/infrastructure/issues/1287#issuecomment-625142917
Expand All @@ -237,7 +243,7 @@ startVMPlaybook()
ssh-keygen -R $(cat playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx)

sed -i -e "s/.*hosts:.*/ hosts: all/g" playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
awk '{print}/^\[defaults\]$/{print "private_key_file = id_rsa"; print "remote_tmp = $HOME/.ansible/tmp"; print "timeout = 60"}' < ansible.cfg > ansible.cfg.tmp && mv ansible.cfg.tmp ansible.cfg
awk '{print}/^\[defaults\]$/{print "private_key_file = id_ed25519"; print "remote_tmp = $HOME/.ansible/tmp"; print "timeout = 60"}' < ansible.cfg > ansible.cfg.tmp && mv ansible.cfg.tmp ansible.cfg

ansible-playbook $verbosity -i playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx -u vagrant -b --skip-tags adoptopenjdk,jenkins${skipFullSetup} playbooks/AdoptOpenJDK_Unix_Playbook/main.yml 2>&1 | tee $WORKSPACE/adoptopenjdkPBTests/logFiles/$gitFork.$newGitBranch.$OS.log
echo The playbook finished at : `date +%T`
Expand All @@ -256,7 +262,7 @@ startVMPlaybook()
if [[ "$testNativeBuild" = true ]]; then
local buildLogPath="$WORKSPACE/adoptopenjdkPBTests/logFiles/${gitFork}.${newGitBranch}.$OS.build_log"

ssh -p ${vagrantPORT} $ssh_args -i $PWD/id_rsa [email protected] "cd /vagrant/pbTestScripts && bash buildJDK.sh $buildBranch $buildFork $jdkToBuild $buildHotspot" 2>&1 | tee $buildLogPath
ssh -p ${vagrantPORT} $ssh_args -i $PWD/${sshKeyFile} [email protected] "cd /vagrant/pbTestScripts && bash buildJDK.sh $buildBranch $buildFork $jdkToBuild $buildHotspot" 2>&1 | tee $buildLogPath
echo The build finished at : `date +%T`
if grep -q '] Error' $buildLogPath || grep -q 'configure: error' $buildLogPath; then
echo BUILD FAILED
Expand All @@ -265,7 +271,7 @@ startVMPlaybook()

if [[ "$runTest" = true ]]; then
local testLogPath="$WORKSPACE/adoptopenjdkPBTests/logFiles/${gitFork}.${newGitBranch}.$OS.test_log"
ssh -p ${vagrantPORT} $ssh_args -i $PWD/id_rsa [email protected] "cd /vagrant/pbTestScripts && bash testJDK.sh" 2>&1 | tee $testLogPath
ssh -p ${vagrantPORT} $ssh_args -i $PWD/${sshKeyFile} [email protected] "cd /vagrant/pbTestScripts && bash testJDK.sh" 2>&1 | tee $testLogPath
echo The test finished at : `date +%T`
if ! grep -q 'FAILED: 0' $testLogPath; then
echo TEST FAILED
Expand All @@ -278,11 +284,11 @@ startVMPlaybook()
if [ "$OS" == "FreeBSD12" -o "$OS" == "CentOS8" -o "$OS" == "CentOS6" ]; then
echo Skipping docker test as we do not set it up on $OS
else
# if ! ssh -p ${vagrantPORT} -i $PWD/id_rsa [email protected] /usr/sbin/service docker status; then
# if ! ssh -p ${vagrantPORT} -i $PWD/${sshKeyFile} [email protected] /usr/sbin/service docker status; then
# echo WARNING: Docker service was not started on the VM ... Attempting to start
# ssh -p ${vagrantPORT} -i $PWD/id_rsa [email protected] /usr/sbin/service docker start
# ssh -p ${vagrantPORT} -i $PWD/${sshKeyFile} [email protected] /usr/sbin/service docker start
# fi
ssh -p ${vagrantPORT} -i $PWD/id_rsa [email protected] sudo docker run alpine /bin/echo Hello World from inside docker
ssh -p ${vagrantPORT} -i $PWD/${sshKeyFile} [email protected] sudo docker run alpine /bin/echo Hello World from inside docker
echo The docker validation finished at : `date +%T`
fi
fi
Expand Down

0 comments on commit f649304

Please sign in to comment.