Vagrantfile 2.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
# -*- mode: ruby -*-

# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.require_version ">= 1.5.0"

$script = <<SCRIPT
# Silly Ubuntu 12.04 doesn't have the
# --stdin option in the passwd utility
echo root:vagrant | chpasswd

cat << EOF >> /etc/hosts
192.168.33.100 cluster1
192.168.33.110 cluster2
192.168.33.120 cluster3
EOF
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box     = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  # Turn off shared folders
  #config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true

  # Begin cluster1
  config.vm.define "cluster1" do |cluster1_config|
    cluster1_config.vm.hostname = "cluster1"

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

    cluster1_config.vm.network :private_network, ip: "192.168.33.100"

    cluster1_config.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--memory", "2048"]
        v.customize ["modifyvm", :id, "--cpus", "2"]
    end
  end
  # End cluster1

 # Begin cluster2
  config.vm.define "cluster2" do |cluster2_config|
    cluster2_config.vm.hostname = "cluster2"

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

    cluster2_config.vm.network :private_network, ip: "192.168.33.110"

    cluster2_config.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--memory", "2048"]
        v.customize ["modifyvm", :id, "--cpus", "2"]
    end
  end
  # End cluster2


  # Begin cluster3
  config.vm.define "cluster3" do |cluster3_config|
    cluster3_config.vm.hostname = "cluster3"

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

    cluster3_config.vm.network :private_network, ip: "192.168.33.120"

    cluster3_config.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--memory", "2048"]
        v.customize ["modifyvm", :id, "--cpus", "2"]
    end
    # Now that all machines are up, provision the group
    # See https://github.com/mitchellh/vagrant/issues/1784 for why
    # we do it here
    cluster3_config.vm.provision :ansible do |ansible|
      # point Vagrant at the location of your playbook you want to run
      ansible.playbook = "../../../playbooks/vagrant-cluster.yml"
78
      ansible.verbose = "vvv"
79 80 81 82 83 84 85
      ansible.inventory_path = "inventory.ini"
      ansible.limit = 'all'
    end
    
  end
  # End cluster3
end