libvm.sh: add vm_setup and vm_rsync

In preparation for being vagrant independent, let's factor out some
things directly into the libvm.

Closes: #394
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2016-07-15 13:30:56 -04:00 committed by Atomic Bot
parent 8942268ecb
commit 194c2bf5cd
3 changed files with 30 additions and 25 deletions

12
Vagrantfile vendored
View File

@ -16,17 +16,9 @@ Vagrant.configure(2) do |config|
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
# turn off the default rsync in the vagrant box and replace by one that
# places it directly to root (and also skip sync'ing .git and any cached
# containers)
# turn off the default rsync in the vagrant box (the vm tooling does this
# for use already)
config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
config.vm.synced_folder ".", "/root/sync", type: "rsync",
rsync__exclude: [".git/", "vagrant/*.tar.gz"],
# override the default args so that
# (1) we don't use --delete (otherwise we will have to regen each time)
# (2) we can tell rsync to skip ignored files
rsync__args: ["--verbose", "--archive", "-z", "--filter", ":- .gitignore"]
config.vm.provider "libvirt" do |libvirt, override|
libvirt.cpus = 2

View File

@ -17,6 +17,31 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# prepares the VM and library for action
vm_setup() {
# If there's already an ssh-config, just use that one. The user might have
# created it for a self-provisioned machine. Otherwise, let's just assume
# we're using vagrant and generate an ssh-config.
if [ ! -f ssh-config ]; then
vagrant ssh-config > "${topsrcdir}/ssh-config"
fi
local sshopts="-F ${topsrcdir}/ssh-config \
-o ControlMaster=auto \
-o ControlPath=${topsrcdir}/ssh.sock \
-o ControlPersist=yes"
export SSH="ssh $sshopts vmcheck"
export SCP="scp $sshopts"
}
vm_rsync() {
pushd ${topsrcdir}
rsync -az --no-owner --no-group --filter ":- .gitignore" \
-e "ssh -F ssh-config" --exclude .git/ . vmcheck:/root/sync
popd
}
# run command in vm
# - $@ command to run
vm_cmd() {

View File

@ -1,23 +1,11 @@
#!/bin/bash
set -euo pipefail
# prepare ssh connection
# If there's already an ssh-config, just use that one. The user might have
# created it for a self-provisioned machine. Otherwise, let's just assume we're
# using vagrant and generate an ssh-config.
if [ ! -f ssh-config ]; then
vagrant ssh-config > ssh-config
echo " ControlMaster auto" >> ssh-config
echo " ControlPath $PWD/ssh.sock" >> ssh-config
echo " ControlPersist yes" >> ssh-config
fi
export SSH="ssh -F $PWD/ssh-config vmcheck"
export SCP="scp -F $PWD/ssh-config"
. ${commondir}/libvm.sh
# create ssh-config if needed and export cmds
vm_setup
# stand up ssh connection and sanity check that it all works
if ! vm_ssh_wait 20; then
echo "ERROR: A running VM is required for 'make vmcheck'."