Skip to content

Instantly share code, notes, and snippets.

@joemiller
Created April 20, 2012 14:02
Show Gist options
  • Select an option

  • Save joemiller/2428915 to your computer and use it in GitHub Desktop.

Select an option

Save joemiller/2428915 to your computer and use it in GitHub Desktop.
parallel provisioning with Vagrant
#!/bin/sh
# concurrency is hard, let's have a beer
MAX_PROCS=4
parallel_provision() {
while read box; do
echo "Provisioning '$box'. Output will be in: $box.out.txt" 1>&2
echo $box
done | xargs -P $MAX_PROCS -I"BOXNAME" \
sh -c 'vagrant provision BOXNAME >BOXNAME.out.txt 2>&1 || echo "Error Occurred: BOXNAME"'
}
## -- main -- ##
# start boxes sequentially to avoid vbox explosions
vagrant up --no-provision
# but run provision tasks in parallel
cat <<EOF | parallel_provision
centos_5_64
centos_5_32
ubuntu_1004_32
ubuntu_1004_64
EOF
@joemiller
Copy link
Author

not bad. reduced the sensu package builds from 30min to 10min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment