Skip to content
Snippets Groups Projects
Vagrantfile 2.94 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`
isLocalMode=true
isServerOverride=ENV['TOMCAT_INIT']||false

if HOSTNAME.strip.eql? "dbis-w65107"
#  puts "Starting box 'isochrone' (server mode)"
  isLocalMode=false
elsif isServerOverride
#  puts "Starting box 'isochrone' (forced server mode)"
  isLocalMode=false
else
#  puts "Starting box 'isochrone-local' (local mode)"
  isLocalMode=true
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.name = (isLocalMode ? "isochrone-local" : "isochrone")
    v.gui = false
    v.cpus = 1
    v.memory = 2048
    v.customize ["modifyvm", :id, "--cpuexecutioncap", "100"]
    v.customize ["modifyvm", :id, "--ostype", "RedHat_64"]
  end

  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)
  config.vm.box = "jayunit100/centos7"

  # Setup of shared folders
  config.vm.synced_folder "conf", "/setup/conf"
  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", path: "bootstrap/prepareEnvironment.sh", args: ["secretPhdPassword#2014!", (isLocalMode ? "true" : "false")]
  config.vm.provision "shell", path: "bootstrap/createDatabase.sh", args: ["niko", "secretPhdPassword#2014!"]
  config.vm.provision "shell", path: "bootstrap/importData.sh", args: ["niko", "secretPhdPassword#2014!", (isLocalMode ? "true" : "false")]

  # Network configuration
  config.vm.network :forwarded_port, guest: 5432, host: 5432, id: "postgresql", 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 isLocalMode
  	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