core.rb 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. def provision_bootstrap(config, role)
  2. # Find all environment variables that begin with
  3. # TFB_* and pass them as an argument. This is a hack to
  4. # let our bootstrap script use environment variables that
  5. # were originally defined on the host
  6. env_arg = ""
  7. ENV.each do |key, array|
  8. if key.start_with? "TFB"
  9. env_arg.concat key
  10. env_arg.concat "="
  11. env_arg.concat array
  12. env_arg.concat "\n"
  13. end
  14. end
  15. env_arg = env_arg.strip
  16. # TODO this will break if the environment contains the ' character,
  17. # so at some point we need to escape the ' character here and unescape
  18. # it in bootstrap.sh
  19. config.vm.provision "shell" do |sh|
  20. sh.path = "../vagrant-common/bootstrap.sh"
  21. sh.privileged = false
  22. sh.args = "'#{env_arg}' '#{role}'"
  23. end
  24. end
  25. def provider_aws(config, role, ip_address='172.16.0.16')
  26. config.vm.provider :aws do |aws, override|
  27. aws.access_key_id = ENV['TFB_AWS_ACCESS_KEY']
  28. aws.secret_access_key = ENV['TFB_AWS_SECRET_KEY']
  29. aws.keypair_name = ENV['TFB_AWS_KEY_NAME']
  30. override.ssh.private_key_path = ENV['TFB_AWS_KEY_PATH']
  31. # Use a boilerplate box - this will be replaced by the AMI
  32. override.vm.box = "dummy"
  33. override.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
  34. # From http://cloud-images.ubuntu.com/trusty/current/
  35. # This is 64-bit Ubuntu 14.04 US east EBS
  36. # See http://cloud-images.ubuntu.com/vagrant/trusty/current/
  37. # for comparison to the Ubuntu Vagrant VirtualBox boxes
  38. aws.ami = "ami-f6bf659e"
  39. override.ssh.username = "ubuntu"
  40. aws.private_ip_address = ip_address
  41. aws.associate_public_ip = true
  42. aws.region = ENV.fetch('TFB_AWS_REGION', 'us-east-1')
  43. aws.subnet_id = ENV['TFB_AWS_SUBNET'] # subnet-2737230f for me
  44. aws.security_groups = [ENV['TFB_AWS_SEC_GROUP']] # sg-871240e2
  45. aws.instance_type = ENV.fetch('TFB_AWS_EC2_TYPE', 'm1.large')
  46. aws.tags = {
  47. 'Project' => 'FrameworkBenchmarks',
  48. 'TFB_role' => role
  49. }
  50. # Setup disk. Defauly is 15GB General Purpose SSD
  51. # Double the default volume size, as we download and
  52. # install a *lot* of stuff
  53. # Documentation is at http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-template.html
  54. aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1',
  55. 'Ebs.VolumeSize' => 15 ,
  56. 'Ebs.DeleteOnTermination' => ENV.fetch('TFB_AWS_EBS_DELETE', true),
  57. 'Ebs.VolumeType' => ENV.fetch('TFB_AWS_EBS_TYPE', 'gp2')
  58. }]
  59. if ENV.fetch('TFB_AWS_EBS_TYPE', 'standard') == 'io1'
  60. aws.block_device_mapping[0]['Ebs.Iops'] = ENV.fetch('TFB_AWS_EBS_IO', '1000')
  61. end
  62. if ENV.fetch('TFB_FORCE_SYNC', "false") == "true"
  63. override.vm.synced_folder "../../..", "/FrameworkBenchmarks"
  64. end
  65. end
  66. end
  67. def provider_virtualbox(config, role)
  68. config.vm.provider :virtualbox do |vb, override|
  69. override.vm.hostname = "TFB-#{role}"
  70. override.vm.box = "ubuntu/trusty64"
  71. if ENV.fetch('TFB_VM_ARCH','64') == "32"
  72. override.vm.box = "ubuntu/trusty32"
  73. end
  74. if ENV.fetch('TFB_SHOW_VM', false)
  75. vb.gui = true
  76. end
  77. if ENV.fetch('TFB_VB_MEM', 2048)
  78. vb.customize ["modifyvm", :id, "--memory", "2048"]
  79. end
  80. override.vm.synced_folder "../../..", "/FrameworkBenchmarks"
  81. if role.eql? "all" or role.eql? "app"
  82. override.vm.network :forwarded_port, guest: 8080, host: 28080
  83. end
  84. end
  85. end