Vagrantfile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. def packages_prepare_wheezy
  4. return <<-EOF
  5. # debian 7 wheezy does not have lz4, but it is available from wheezy-backports:
  6. echo "deb http://http.debian.net/debian wheezy-backports main" > /etc/apt/sources.list.d/wheezy-backports.list
  7. EOF
  8. end
  9. def packages_prepare_precise
  10. return <<-EOF
  11. # ubuntu 12.04 precise does not have lz4, but it is available from a ppa:
  12. add-apt-repository -y ppa:gezakovacs/lz4
  13. EOF
  14. end
  15. def packages_centos
  16. return <<-EOF
  17. yum install -y epel-release
  18. yum update -y
  19. yum install -y python34 python34-devel
  20. ln -s /usr/bin/python3.4 /usr/bin/python3
  21. yum install -y openssl-devel openssl
  22. yum install -y libacl-devel libacl
  23. yum install -y lz4-devel
  24. yum install -y fuse-devel fuse pkgconfig
  25. yum install -y fakeroot gcc git
  26. yum install -y python-pip
  27. pip install virtualenv
  28. EOF
  29. end
  30. def packages_debianoid
  31. return <<-EOF
  32. apt-get update
  33. apt-get install -y python3-dev python3-setuptools
  34. apt-get install -y libssl-dev libacl1-dev liblz4-dev
  35. apt-get install -y libfuse-dev fuse pkg-config
  36. apt-get install -y fakeroot build-essential git
  37. # this way it works on older dists (like ubuntu 12.04) also:
  38. easy_install3 pip
  39. pip3 install virtualenv
  40. EOF
  41. end
  42. def packages_freebsd
  43. return <<-EOF
  44. pkg install -y python34 py34-setuptools34
  45. ln -s /usr/local/bin/python3.4 /usr/local/bin/python3
  46. pkg install -y openssl liblz4
  47. pkg install -y fusefs-libs pkgconf
  48. pkg install -y fakeroot git
  49. easy_install-3.4 pip
  50. pip3 install virtualenv
  51. # make FUSE work
  52. echo 'fuse_load="YES"' >> /boot/loader.conf
  53. echo 'vfs.usermount=1' >> /etc/sysctl.conf
  54. kldload fuse
  55. sysctl vfs.usermount=1
  56. pw groupmod operator -M vagrant
  57. EOF
  58. end
  59. def packages_darwin
  60. return <<-EOF
  61. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  62. brew update
  63. # this installs osxfuse 2.8.0 (which is based on libfuse 2.7.3).
  64. # llfuse later complains about needing (libfuse) 2.8.0 at least.
  65. #brew install caskroom/cask/brew-cask
  66. #brew cask install osxfuse # needs cask install because of apple's unsigned kext ban
  67. # get osxfuse 3.0.x pre-release code from github:
  68. curl https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.0.5/osxfuse-3.0.5.dmg -L >osxfuse.dmg
  69. MOUNTDIR=$(echo `hdiutil mount osxfuse.dmg | tail -1 | awk '{$1="" ; print $0}'` | xargs -0 echo) \
  70. && sudo installer -pkg "${MOUNTDIR}/Extras/FUSE for OS X 3.0.5.pkg" -target /
  71. brew install openssl
  72. brew install lz4
  73. # looks dirty, is there a better way without root?:
  74. mkdir -p /usr/local/opt/lz4
  75. ln -s /usr/local/Cellar/lz4/r*/include /usr/local/opt/lz4/
  76. ln -s /usr/local/Cellar/lz4/r*/lib /usr/local/opt/lz4/
  77. brew install fakeroot
  78. brew install pyenv
  79. if which pyenv > /dev/null; then
  80. eval "$(pyenv init -)"
  81. fi
  82. pyenv install 3.4.3
  83. pyenv global 3.4.3
  84. pyenv rehash
  85. python -m pip install --user virtualenv
  86. EOF
  87. end
  88. def prepare_user(boxname)
  89. return <<-EOF
  90. echo export 'PATH=/usr/local/bin:$PATH' >> ~/.profile
  91. . ~/.profile
  92. # initialize python on darwin
  93. if which pyenv > /dev/null; then
  94. eval "$(pyenv init -)"
  95. fi
  96. cd /vagrant/borg
  97. python -m virtualenv --python=python3 borg-env
  98. . borg-env/bin/activate
  99. cd borg
  100. pip install -U pip setuptools
  101. pip install 'llfuse<0.41' # 0.41 does not install due to UnicodeDecodeError
  102. pip install -r requirements.d/development.txt
  103. pip install -e .
  104. echo
  105. echo "Run:"
  106. echo " vagrant rsync #{boxname}"
  107. echo " vagrant ssh #{boxname} -c 'cd project/path; ...'"
  108. EOF
  109. end
  110. def fix_perms
  111. return <<-EOF
  112. chown -R vagrant /vagrant/borg
  113. EOF
  114. end
  115. Vagrant.configure(2) do |config|
  116. # use rsync to copy content to the folder
  117. config.vm.synced_folder ".", "/vagrant/borg/borg", :type => "rsync"
  118. # do not let the VM access . on the host machine via the default shared folder!
  119. config.vm.synced_folder ".", "/vagrant", disabled: true
  120. # fix permissions on synced folder
  121. config.vm.provision "fix perms", :type => :shell, :inline => fix_perms
  122. config.vm.provider :virtualbox do |v|
  123. #v.gui = true
  124. v.cpus = 2
  125. end
  126. config.vm.define "centos7" do |b|
  127. b.vm.box = "centos/7"
  128. b.vm.provision "packages centos7 64", :type => :shell, :inline => packages_centos
  129. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("centos7_64")
  130. end
  131. config.vm.define "trusty64" do |b|
  132. b.vm.box = "ubuntu/trusty64"
  133. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  134. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("trusty64")
  135. end
  136. config.vm.define "precise32" do |b|
  137. b.vm.box = "ubuntu/precise32"
  138. b.vm.provision "packages prepare precise", :type => :shell, :inline => packages_prepare_precise
  139. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  140. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("precise32")
  141. end
  142. config.vm.define "jessie64" do |b|
  143. b.vm.box = "debian/jessie64"
  144. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  145. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("jessie64")
  146. end
  147. config.vm.define "wheezy32" do |b|
  148. b.vm.box = "puppetlabs/debian-7.8-32-nocm"
  149. b.vm.provision "packages prepare wheezy", :type => :shell, :inline => packages_prepare_wheezy
  150. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  151. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("wheezy32")
  152. end
  153. # BSD
  154. config.vm.define "freebsd" do |b|
  155. b.vm.box = "geoffgarside/freebsd-10.2"
  156. b.vm.provision "packages freebsd", :type => :shell, :inline => packages_freebsd
  157. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("freebsd")
  158. end
  159. # OS X
  160. config.vm.define "darwin" do |b|
  161. b.vm.box = "jhcook/yosemite-clitools"
  162. b.vm.provision "packages darwin", :type => :shell, :privileged => false, :inline => packages_darwin
  163. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("darwin")
  164. end
  165. end