Created
April 20, 2012 14:02
-
-
Save joemiller/2428915 to your computer and use it in GitHub Desktop.
parallel provisioning with Vagrant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not bad. reduced the sensu package builds from 30min to 10min