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

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.provision "file", source: "id_rsa", destination: "/home/vagrant/.ssh/id_rsa"
    config.vm.provision "file", source: "id_rsa.pub", destination: "/home/vagrant/.ssh/id_rsa.pub"
    config.vm.provision "file", source: "known_hosts", destination: "/home/vagrant/.ssh/known_hosts"
    config.vm.provision "file", source: "hosts", destination: "/home/vagrant/hosts"

    config.vm.provision "shell", inline: "mv /home/vagrant/hosts /etc/hosts"
    config.vm.provision "shell", privileged: false, inline: "chmod 400 /home/vagrant/.ssh/id_rsa"
    config.vm.provision "shell", privileged: false, inline: "cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys"
    config.vm.provision "shell", privileged: false, inline: "chmod 600 /home/vagrant/.ssh/authorized_keys"
    $java_inst = <<-END
        wget -q --no-cookies --no-check-certificate \
        --header 'Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie' \
        'http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.rpm' \
        -O /tmp/jdk.rpm;

        sudo yum -y localinstall /tmp/jdk.rpm;
        sudo yum -y install unzip;

    END
    config.vm.provision "shell", inline: $java_inst

    config.vm.define "nc2" do |nc|
        nc.vm.box = "bento/centos-6.7"
        nc.vm.hostname = "nc2"
        nc.vm.network "private_network", ip: "10.10.0.4"
        config.vm.provider "virtualbox" do |v|
            v.memory = 3096
            v.cpus = 2
        end
    end
    config.vm.define "nc1" do |nc|
        nc.vm.box = "bento/centos-6.7"
        nc.vm.hostname = "nc1"
        nc.vm.network "private_network", ip: "10.10.0.3"
        config.vm.provider "virtualbox" do |v|
            v.memory = 3096
            v.cpus = 2
        end
    end

    config.vm.define "cc" do |cc|
        cc.vm.box = "bento/centos-6.7"
        cc.vm.hostname = "cc"
        cc.vm.network "private_network", ip: "10.10.0.2"
        config.vm.provider "virtualbox" do |v|
            v.memory = 1024
            v.cpus = 1
        end
    end

end
