Browse Source

Remove dev parameter and always use local clone

Hamilton Turner 11 years ago
parent
commit
9fc1d12b75
2 changed files with 53 additions and 31 deletions
  1. 44 20
      toolset/deployment/vagrant/Vagrantfile
  2. 9 11
      toolset/deployment/vagrant/bootstrap.sh

+ 44 - 20
toolset/deployment/vagrant/Vagrantfile

@@ -8,14 +8,27 @@ else
   provider = (ARGV[2] || ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym
 end
 
-if provider == :"aws" \
-  and !(ENV['TFB_AWS_ACCESS_KEY'] and ENV['TFB_AWS_SECRET_KEY'] \
+if provider == :"aws"
+  # Check required variables
+  if !(ENV['TFB_AWS_ACCESS_KEY'] and ENV['TFB_AWS_SECRET_KEY'] \
         and ENV['TFB_AWS_KEY_NAME'] and ENV['TFB_AWS_KEY_PATH'])
-  abort 'If you want to use the AWS provider, you must provide these four variables: 
-  TFB_AWS_ACCESS_KEY : Your Amazon Web Services Access Key
-  TFB_AWS_SECRET_KEY : Your Amazon Web Services Secret Access Key
-  TFB_AWS_KEY_NAME   : The name of the keypair you are using
-  TFB_AWS_KEY_PATH   : Path to the *.pem file for the keypair you are using'
+    abort 'If you want to use the AWS provider, you must provide these four variables: 
+    TFB_AWS_ACCESS_KEY : Your Amazon Web Services Access Key
+    TFB_AWS_SECRET_KEY : Your Amazon Web Services Secret Access Key
+    TFB_AWS_KEY_NAME   : The name of the keypair you are using
+    TFB_AWS_KEY_PATH   : Path to the *.pem file for the keypair you are using'
+  end
+
+  # Print warning
+    warning = "\033[33m\
+WARNING: FrameworkBenchmarks is disabling folder sync between your
+local working copy and Amazon Web Services - the ~/FrameworkBenchmarks
+directory in your VM will be a git clone of TechEmpower/FrameworkBenchmarks. 
+You can re-enable folder sync using 
+    $ TFB_FORCE_SYNC=true vagrant up --provider=aws
+but be aware that you will need to upload ~2GB to Amazon before you can use
+the VM as normal.\033[0m"
+  puts warning
 end
 
 # Helps with finding current OS
@@ -85,11 +98,6 @@ Vagrant.configure("2") do |config|
   config.vm.hostname = "TFB"
   config.vm.box = "ubuntu/trusty64"
 
-  # Use a non-standard value here as most home networks are 
-  # 192.168.X.X or 10.X.X.X and we cannot have a collision 
-  # with the host network
-  config.vm.network "private_network", ip: "172.16.16.16"  
-
   # Add settings for advanced users doing development
   config.vm.synced_folder "../../..", "/FrameworkBenchmarks"
   config.vm.network :forwarded_port, guest: 8080, host: 28080
@@ -103,6 +111,11 @@ Vagrant.configure("2") do |config|
     if ENV['TFB_VM_ARCH'] and ENV['TFB_SHOW_VM'] == "32"
       override.vm.box = "ubuntu/trusty32"
     end
+
+    # Use a non-standard value here as most home networks are 
+    # 192.168.X.X or 10.X.X.X and we cannot have a collision 
+    # with the host network
+    override.vm.network "private_network", ip: "172.16.16.16"
   end
 
   # Requires the vagrant-aws plugin from github.com/mitchellh/vagrant-aws
@@ -126,19 +139,30 @@ Vagrant.configure("2") do |config|
     # If you would like to override
     # aws.region = "us-east-1"
     # aws.security_groups = ["default"]
+
+    aws.tags = {
+      'Project' => 'FrameworkBenchmarks',
+      'TFB_role' => 'integrated'
+     }
     
     # Currently this uses 'previous generation' instance names
     # See: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
     aws.instance_type = "m1.small"
 
     # Disable support for synced folders
-    override.vm.synced_folder "../../..", "/FrameworkBenchmarks", disabled: true
+    if !(ENV['TFB_FORCE_SYNC'] and ENV['TFB_FORCE_SYNC'] == "true")
+      override.vm.synced_folder "../../..", "/FrameworkBenchmarks", disabled: true
+    end
+  end
+  
+  config.vm.provision :shell do |sh|
+    sh.path = "bootstrap.sh"
+    
+    # We run the bootstrap as the normal vagrant user, not as root
+    sh.privileged = false
+    
+    # If you need arguments, you must pass them in, becuase Vagrant 
+    # cleans the environment before running the provision script
+    # sh.args = ""
   end
-
-  # We run the bootstrap as the normal vagrant user, not as root
-  # You can pass arguments to the bootstrap.sh by setting the variable
-  # SHELL_ARGS. At the moment, the only arg it understands is 'dev' for 
-  # developer mode. For example:
-  #   $ SHELL_ARGS="dev" vagrant up
-  config.vm.provision :shell, :path => "bootstrap.sh", privileged: false, args: ENV['SHELL_ARGS']
 end

+ 9 - 11
toolset/deployment/vagrant/bootstrap.sh

@@ -5,6 +5,7 @@
 # Intentionally uses ~, $HOME, and $USER so that the 
 # same script can work for VirtualBox (username vagrant)
 # and Amazon (username ubuntu)
+#
 
 if [ ! -e "~/.firstboot" ]; then
 
@@ -16,16 +17,10 @@ if [ ! -e "~/.firstboot" ]; then
   echo "export TFB_DATABASE_USER=$USER" >> ~/.bash_profile
   echo "export TFB_CLIENT_IDENTITY_FILE=$HOME/.ssh/id_rsa" >> ~/.bash_profile
   echo "export TFB_DATABASE_IDENTITY_FILE=$HOME/.ssh/id_rsa" >> ~/.bash_profile
-  if [ "$1" == "dev" ]; then
-    echo "FrameworkBenchmarks: Running in developer mode"
-    echo "export FWROOT=/FrameworkBenchmarks" >> ~/.bash_profile 
-    ln -s /FrameworkBenchmarks ~/FrameworkBenchmarks
-    if [ -e "/FrameworkBenchmarks/benchmark.cfg" ]; then
-      echo "You have a benchmark.cfg file that will interfere with Vagrant, moving"
-      mv /FrameworkBenchmarks/benchmark.cfg /FrameworkBenchmarks/benchmark.cfg.backup
-    fi
-  else
-    echo "export FWROOT=$HOME/FrameworkBenchmarks" >> ~/.bash_profile 
+  echo "export FWROOT=$HOME/FrameworkBenchmarks" >> ~/.bash_profile 
+  if [ -e "~/FrameworkBenchmarks/benchmark.cfg" ]; then
+    echo "You have a benchmark.cfg file that will interfere with Vagrant, moving to benchmark.cfg.bak"
+    mv ~/FrameworkBenchmarks/benchmark.cfg ~/FrameworkBenchmarks/benchmark.cfg.bak
   fi
   source ~/.bash_profile
 
@@ -42,7 +37,10 @@ if [ ! -e "~/.firstboot" ]; then
   sudo apt-get install -y python-pip
 
   # Initial project setup
-  if [ "$1" != "dev" ]; then
+  if [ -d "/FrameworkBenchmarks" ]; then
+    ln -s /FrameworkBenchmarks $FWROOT
+  else
+    # If there is no synced folder, clone the project
     git clone https://github.com/TechEmpower/FrameworkBenchmarks.git $FWROOT
   fi
   sudo pip install -r $FWROOT/config/python_requirements.txt