Changes needed for vagrant in the ODL Priv Cloud
[releng/builder.git] / vagrant / baseline / Vagrantfile
index dd09c1b48e15f0e41eec20cb2ddded2056e81351..8a6080c850c9ab88c4167a3d0303865ddb707e4a 100644 (file)
@@ -13,23 +13,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   # getting the ssh key for some reason, root does
   # so use that
   config.ssh.username = 'root'
-  
-  # Fedora and EL systems default to requiring a tty for sudo
-  if (ENV['RSPTY'] == 'default')
-    config.ssh.pty = false
-  else
-    config.ssh.pty = true
-  end
-
-  # The rackspace provider by default tries to rsync
-  # the local folder / vagrant box to /vagrant
-  # unfortunately, even with config.ssh.pty = true
-  # this fails because it doesn't recognize the pty requirement
-  # when doing the sudo based rsync (not that it needs to sudo
-  # when doing things as root). To avoid this, disable the
-  # default sync, we don't need it anyway.
-  config.vm.synced_folder '.', '/vagrant', :disabled => true
 
+  # DEPRECATED
+  # ==========
+  #
+  # NOTE: The Rackspace provider section is deprecated as we are moving into a
+  # private OpenStack cloud. It may be revived after we've migrated and have a
+  # chance to do work to reconfigure the Rackspace public cloud to work for
+  # burst access
+  #
   # make sure to set the following in your
   # ~/.vagrant.d/boxes/dummy/0/rackspace/Vagrantfile
   # rs.username
@@ -53,21 +45,60 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
     # Default to the Fedora 20 image unless overridden by a RSIMAGE
     # environment variable
-    if ENV['RSIMAGE']
-      rs.image = ENV['RSIMAGE']
+    if ENV['IMAGE']
+      rs.image = ENV['IMAGE']
     else
       rs.image = 'Fedora 20 (Heisenbug) (PVHVM)'
     end
   end
+  # /DEPRECATED
 
-  # Do a full system update and force enforcing on (it's in permissive
-  # by default in the rackspace base images)
-  config.vm.provision 'shell', path: 'bootstrap.sh'
+  # Configuration used by ODL Private cloud
+  # Should be mostly usable by any OpenStack cloud that can
+  # utilize upstream cloud images
+  config.vm.provider :openstack do |os, override|
+    if ENV['BOX']
+      override.vm.box = ENV['BOX']
+    else
+      override.vm.box = 'dummy'
+    end
+    config.ssh.username = 'centos'
+    os.flavor = 'm1.small'
+
+    # require an IMAGE to be passed in
+    # IMAGE must be a human name and not an image ID!
+    if ENV['IMAGE']
+      os.image = ENV['IMAGE']
+    else
+      os.image = 'BAD IMAGE'
+      override.ssh.username = 'baduser'
+    end
+
+    case ENV['IMAGE']
+      when /.*ubuntu.*/i
+        override.ssh.username = 'ubuntu'
+
+      when /.*fedora.*/i
+        override.ssh.username = 'fedora'
+
+        # take care of the tty requirement by fedora for sudo
+        os.user_data = "#!/bin/bash
+/bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
+
+      when /.*centos.*/i
+        override.ssh.username = 'centos'
+
+        # take care of the tty requirement by centos for sudo
+        os.user_data = "#!/bin/bash
+/bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
+    end
+
+  end
 
-  # disable the default requiretty for sudo that Fedora and CentOS have
-  config.vm.provision 'shell', path: 'remove_requiretty.sh'
+  # Do a full system update and enable enforcing if needed
+  config.vm.provision 'shell', path: '../lib/baseline.sh'
 
   # Execute a system clean-up in prep for imaging so that this base
   # image can be used for other Rackspace Vagrant configurations
-  config.vm.provision 'shell', path: 'system_reseal.sh'
+  config.vm.provision 'shell', path: '../lib/system_reseal.sh'
 end