# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/bionic64"

  config.vm.hostname = "training.plone.org"
  config.vm.network :forwarded_port, guest: 8080, host: 8080

  # Allow the creation of symbolic links in the shared folder.
  # This is needed for some builds with cmmi and for omelette to work.
  # 'v-root' is the default-name for the primary volume.
  config.vm.provider :virtualbox do |vb|
    vb.customize  ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
    vb.customize  ["modifyvm", :id, "--natdnshostresolver1", "on"]
    vb.customize  ["modifyvm", :id, "--natdnsproxy1", "on"]
    vb.memory = "1536"
  end

  # A workaround for missing symbolic links on windows:
  # config.vm.synced_folder "eggs/", "/home/vagrant/buildout-cache/eggs/"

  # Read initial package index information + upgrade
  config.vm.provision :shell, inline: <<-SHELL
      apt-get update
      apt-get -y upgrade
  SHELL

  # We need to install puppet on the guest before we can use it
  config.vm.provision :shell, inline: <<-SHELL
      apt-get install -y puppet
  SHELL

  # ensure we have the packages we need
  config.vm.provision :puppet do |puppet|
      puppet.manifests_path = "manifests"
      puppet.manifest_file  = "packages.pp"
  end

  # Create a Putty-style keyfile for Windows users
  config.vm.provision :shell do |shell|
      shell.path = "manifests/host_setup.sh"
      shell.args = RUBY_PLATFORM
  end

  # install plone
  config.vm.provision :puppet do |puppet|
      puppet.manifests_path = "manifests"
      puppet.manifest_file  = "plone.pp"
  end


end
