= Vagrant =
 * https://www.vagrantup.com

== vagrantfile ==
 * https://www.vagrantup.com/docs/vagrantfile/

=== sample file for ubuntu xenial ===
{{{#!highlight ruby
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.network "forwarded_port", guest: 8080, host: 18080, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9990, host: 19990, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9000, host: 19000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9001, host: 19001, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9002, host: 19002, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9003, host: 19003, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 4200, host: 14200, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 5672, host: 15672, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 15672, host: 25672, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8000, host: 18000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 5000, host: 15000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 1433, host: 11433, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9042, host: 19042, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 27017, host: 37017, host_ip: "127.0.0.1"

  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "2048"
    vb.name = "UbuntuVM"
    file_to_disk = "dockerdata.vmdk"
    unless File.exist?(file_to_disk)
        vb.customize [ "createmedium", "disk", "--filename", file_to_disk, "--format", "vmdk", "--size", 1024 * 10 ]
    end
    vb.customize [ "storageattach", "UbuntuVM" , "--storagectl", "SCSI", "--port", "2", "--device", "0", "--type", "hdd", "--medium", file_to_disk]
  end

  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install apt-transport-https  ca-certificates curl  software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    apt-get update
    apt-get install openjdk-8-jdk maven nodejs npm docker-ce -y
    usermod -a vagrant -G docker
    dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
    chown root:root /swapfile1
    chmod 0600 /swapfile1
    mkswap /swapfile1
    swapon /swapfile1
    echo "/swapfile1 none swap sw 0 0" >> /etc/fstab
    # nodejs stuff
    apt-get purge nodejs npm
    curl -sL https://deb.nodesource.com/setup_9.x | bash -
    apt-get install -y nodejs
    # prepare new disk for docker data ...
    echo -e "n\np\n1\n\n\nw" | fdisk /dev/sdc
    mkfs.ext4 /dev/sdc1
    mkdir -p /mnt/dockerdata
    mount /dev/sdc1 /mnt/dockerdata/
    echo "/dev/sdc1 /mnt/dockerdata ext4 defaults 0 0 " >> /etc/fstab
    echo -e "{\n    \"data-root\": \"/mnt/dockerdata\"\n}" > /etc/docker/daemon.json
  SHELL
end
}}}

== vagrant init ==
{{{
vagrant init [name [url]]

This initializes the current directory to be a Vagrant environment by creating an initial Vagrantfile if one does not already exist.
If a first argument is given, it will prepopulate the config.vm.box setting in the created Vagrantfile.
If a second argument is given, it will prepopulate the config.vm.box_url setting in the created Vagrantfile.

Create a base Vagrantfile:
$ vagrant init hashicorp/precise64

Create a minimal Vagrantfile (no comments or helpers):
$ vagrant init -m hashicorp/precise64

Create a Vagrantfile with the specific box, from the specific box URL:
$ vagrant init my-company-box https://boxes.company.com/my-company.box
}}}

== vagrant up ==
{{{
vagrant up [name|id]
This command creates and configures guest machines according to your Vagrantfile.
}}}

== centos 7 ==
{{{
# https://app.vagrantup.com/centos/boxes/7
vagrant init centos/7
# customize the Vagrantfile
vagrant up 
}}}