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

BASE_BOX = "ubuntu/xenial64"
BRIDGE_NET = "{{vm.bridge_network}}"

$script = <<SCRIPT
    echo I am provisioning...
    sudo adduser --home /home/ansible --shell /bin/bash --uid 1001 --disabled-password ansible
    sudo mkdir -p /home/ansible/.ssh
    sudo cat /etc/sudoers
    echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAmJSdmj03d4fnZUuRByevPDNiReEk1fRL+7F9WPCo5zn+r5Oj84HXxd4P03DNXeGSBYmUAnsTqYEGdkjkpSrKfMm9bv8amL7hUC+Mzb+wOmXmyX1cw/SearYCBQRCz1s5p7I9+PO7XWaC0VJ99LUm1Bp4JM149U5X0Y3M2j2XV+0= RSA-1024" | sudo tee -a /home/ansible/.ssh/authorized_keys
    sudo chmod 600 /home/ansible/.ssh/authorized_keys
    sudo chmod 700 /home/ansible/.ssh
    sudo chown -R ansible /home/ansible
    sudo echo "ansible ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
    sudo apt -y update && sudo apt install -y python-minimal
    date > /etc/vagrant_provisioned_at
SCRIPT

Vagrant.configure("2") do |config|

  config.vm.define "dkhost01" do |dkhost01|

    dkhost01.vm.hostname = "dkhost01"

    dkhost01.vm.box = BASE_BOX
    dkhost01.vm.box_check_update = true

    dkhost01.vm.network "public_network", bridge: BRIDGE_NET

    dkhost01.vm.synced_folder '.', '/vagrant', disabled: true

    dkhost01.vm.provision "shell", inline: $script

    dkhost01.vm.provider "virtualbox" do |vb|
      vb.name = "dkhost01"
      vb.gui = false
      vb.memory = "2048"
      vb.cpus = 2

      #vb.customize ["modifyvm", :id, "--autostart-enabled", "on"]
      #vb.customize ["modifyvm", :id, "--autostart-delay", "30"]

      vb.customize ["modifyvm", :id, "--macaddress2", "0800271a4d51"]
    end

  end

  config.vm.define "dkhost02" do |dkhost|

    dkhost.vm.hostname = "dkhost02"

    dkhost.vm.box = BASE_BOX
    dkhost.vm.box_check_update = true

    dkhost.vm.network "public_network", bridge: BRIDGE_NET

    dkhost.vm.synced_folder '.', '/vagrant', disabled: true

    dkhost.vm.provision "shell", inline: $script

    dkhost.vm.provider "virtualbox" do |vb|
      vb.name = "dkhost01"
      vb.gui = false
      vb.memory = "2048"
      vb.cpus = 2

      #vb.customize ["modifyvm", :id, "--autostart-enabled", "on"]
      #vb.customize ["modifyvm", :id, "--autostart-delay", "30"]

      vb.customize ["modifyvm", :id, "--macaddress2", "0800273D10E4"]
    end

  end

end
