Skip to content
Snippets Groups Projects
Vagrantfile 3.95 KiB
Newer Older
# -*- mode: ruby -*-
# vi: set ft=ruby :

REQUIRED_PLUGINS = %w(vagrant-cachier vagrant-vbguest vagrant-triggers)
exit unless REQUIRED_PLUGINS.all? do |plugin|
  Vagrant.has_plugin?(plugin) || (
    puts "The #{plugin} plugin is required. Please install it with:"
    puts "$ vagrant plugin install #{plugin}"
    false
  )
end

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
HOSTNAME=`hostname -s`

deployAllDatasets=false
hostnameDbisIsochrone="dbis-w65107"
hostnameDbisTests="dbis-tests"
isJenkinsDeploy=false
isLocalDeploy=false
isServerOverride=ENV['TOMCAT_INIT']||false
if HOSTNAME.strip.eql? hostnameDbisTests
#  puts "Starting box 'isochrone-jenkins'"
  isJenkinsDeploy=true
  vname="isochrone-jenkins"
elsif HOSTNAME.strip.eql? hostnameDbisIsochrone
#  puts "Starting box 'isochrone' (server mode)"
  deployAllDatasets=true
  isLocalDeploy=false
  vname="isochrone"
elsif isServerOverride
#  puts "Starting box 'isochrone' (forced server mode)"
  deployAllDatasets=false
  isLocalDeploy=false
  vname="isochrone"
#  puts "Starting box 'isochrone-local' (local mode)"
  deployAllDatasets=false
  isLocalDeploy=true
  vname="isochrone-local"
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.boot_timeout = 600

  # Hardware configuration
  # WARNING: Be VERY careful with this settings!!!
  #  -> giving the client more cores can SLOW DOWN the VM (if there is not enough workload on the guest, two less cores on the host...)
  config.vm.provider "virtualbox" do |v|
    v.gui = false
    v.cpus = 1
    v.memory = 2048
    v.customize ["modifyvm", :id, "--cpuexecutioncap", "100"]
    v.customize ["modifyvm", :id, "--ostype", "RedHat_64"]
    v.customize ["modifyvm", :id, "--nictype1", "virtio"]
    v.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "on"]
  config.trigger.after :destroy do
    info "Deleting temporary synced log folders"
  # Enable vagrant-cachier plugin
  config.cache.enable :yum

  # Information about the box itself (name from vagrantcloud)
User expired's avatar
User expired committed
  config.vm.box = "box-cutter/centos72"

  # Setup of shared folders
  config.vm.synced_folder "conf", "/setup/conf"
  config.vm.synced_folder "data", "/opt/data", create: true
  config.vm.synced_folder "img", "/setup/img"
  config.vm.synced_folder "log/postgresql", "/var/log/postgresql", create: true, owner: 26, group: 26
  config.vm.synced_folder "log/bootstrap", "/var/log/vagrant_bootstrap", create: true, owner: "vagrant", group: "vagrant"

  # Setup environment on startup (done using a shell script)
  config.vm.provision "shell", keep_color: true, path: "bootstrap/prepareEnvironment.sh", args: ["secretPhdPassword#2014!", (isLocalDeploy ? "true" : "false"), (isJenkinsDeploy ? "true" : "false")]
  config.vm.provision "shell", keep_color: true, path: "bootstrap/createDatabase.sh", args: ["niko", "secretPhdPassword#2014!"]
  config.vm.provision "shell", keep_color: true, path: "bootstrap/importData.sh", args: ["niko", "secretPhdPassword#2014!", (deployAllDatasets ? "true" : "false")]
  # Optionally activate database logging (for queryTimeLogging this is done in the testcase itself now)
  #config.vm.provision "shell", path: "bootstrap/activateDatabaseLogging.sh"

  # Network configuration
  config.vm.network :forwarded_port, guest: 5432, host: 5432, id: "postgresql", auto_correct: false
  config.vm.network :forwarded_port, guest: 7473, host: 7473, id: "neo4j-ssl", auto_correct: false
  config.vm.network :forwarded_port, guest: 7474, host: 7474, id: "neo4j", auto_correct: false
  config.vm.network :forwarded_port, guest: 80,   host: 8000, id: "httpd", auto_correct: false
  unless (isLocalDeploy || isJenkinsDeploy)
  	config.vm.network :forwarded_port, guest: 8080, host: 8080, id: "tomcat", auto_correct: false
  end
#  config.vm.network :private_network, :ip => '192.168.4.50'
#  config.vm.network :public_network
end