VAGRANTFILE_API_VERSION = "2"

GIT_BRANCH          = "master"
GIT_URL             = "https://github.com/leapp-to/ansible-devel-env.git"
GIT_CLONE_DIR       = "ansible-devel-env"
HOME                = "/home/vagrant"
LEAPP_HOME          = "#{HOME}/leapp"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "fedora/26-cloud-base"
    config.vm.define "leapp-development-environment"
    config.vm.hostname = "leapp-devenv"

    config.vm.provider :libvirt do |libvirt|
        libvirt.memory = 2048
        libvirt.cpus = 1
        libvirt.cpu_mode = 'host-passthrough'
        libvirt.nested = true

        libvirt.management_network_name = 'leapp-devenv-network'
        libvirt.management_network_address = '192.168.124.0/24'
    end

    config.vm.provision "shell", inline: "dnf -y upgrade && "\
        "dnf -y install "\
        "ansible "\
        "docker "\
        "git"

    config.vm.provision "shell", inline: "cd #{HOME} && "\
        "rm -rf #{GIT_CLONE_DIR} && "\
        "git clone #{GIT_URL} #{GIT_CLONE_DIR} && "\
        "cd #{GIT_CLONE_DIR} && git checkout #{GIT_BRANCH} && "\
        "ansible-playbook ansible/leapp_dev.yml 2>&1 | tee #{HOME}/leapp-setup.log", privileged: false
    config.vm.provision "shell", inline: "systemctl enable docker"
    config.vm.provision "shell", inline: "systemctl start docker"

end
