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

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what # you're doing.
Vagrant.configure("2") do |config|
  config.vm.hostname = "archlinux"
  config.vm.box = "archlinux/archlinux"
  id_rsa_pub = File.read("./.vagrant/vagrant.key.pub")
  config.vm.provision "copy ssh public key", type: "shell",
    inline: "echo \"#{id_rsa_pub}\" >> /home/vagrant/.ssh/authorized_keys"
  #config.ssh.username = 'vagrant'
  #config.ssh.password = 'vagrant'
  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true
  config.vm.network :forwarded_port, guest: 22, host: 47111, auto_correct: true
  #config.ssh.insert_key = true
  #config.ssh.forward_agent = true

  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
  config.vm.network "private_network", type: "dhcp", name: "vboxnet0"
  config.vm.synced_folder "./", "/vagrant_files"

  config.vm.provider "virtualbox" do |vb|
  # Display the VirtualBox GUI when booting the machine
  vb.gui = false

  # Customize the amount of memory on the VM:
  vb.memory = "8192"
  vb.customize ["modifyvm", :id, "--vram", "256"]
  end

  config.vm.provision "ansible" do |ansible|
    ansible.verbose = "v" 
    ansible.raw_arguments  = [ 
    "--private-key=./.vagrant/vagrant.key"
    ]   
    ansible.playbook = "playbook.yml"
  end
end