Vagrantfile 4.67 KB
Newer Older
1 2 3
VAGRANTFILE_API_VERSION = "2"
GITCONFIG = `cat $HOME/.gitconfig`

4 5
Vagrant.require_version ">= 1.5"

6 7 8
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true

9 10 11
  config.vm.network "forwarded_port", guest: 5354, host: 5354, protocol: "tcp"
  config.vm.network "forwarded_port", guest: 5354, host: 5354, protocol: "udp"

12
  config.vm.provider "virtualbox" do |vb, override|
13
    vb.customize ["modifyvm", :id, "--memory", "2048"]
14 15 16
    if not RUBY_PLATFORM.downcase.include?("mswin")
      vb.customize ["modifyvm", :id, "--cpus", `awk "/^processor/ {++n} END {print n}" /proc/cpuinfo 2> /dev/null || sh -c 'sysctl hw.logicalcpu 2> /dev/null || echo ": 2"' | awk \'{print \$2}\' `.chomp ]
    end
17
    vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
18

19
    override.vm.synced_folder "../..", "/opt/stack/designate"
20 21

    if File.directory?("../../../python-designateclient")
22
      override.vm.synced_folder "../../../python-designateclient", "/opt/stack/python-designateclient"
23 24
    end

25 26 27 28
    if File.directory?("../../../designate-dashboard")
      override.vm.synced_folder "../../../designate-dashboard", "/opt/stack/designate-dashboard"
    end

29 30 31 32
    if File.directory?("../../../designate-tempest-plugin")
      override.vm.synced_folder "../../../designate-tempest-plugin", "/opt/stack/designate-tempest-plugin"
    end

33 34 35 36 37 38 39 40 41 42
    if File.directory?("../../../devstack")
      override.vm.synced_folder "../../../devstack", "/home/vagrant/devstack"
    end

    if File.directory?("../../../tempest")
      override.vm.synced_folder "../../../tempest", "/opt/stack/tempest"
    end

    if File.directory?("../../../rally")
      override.vm.synced_folder "../../../rally", "/opt/stack/rally"
43 44 45
    end
  end

46
  config.vm.provider :libvirt do |lv, override|
47 48 49 50 51 52 53
    lv.graphics_ip = '0.0.0.0'
    lv.nested = true
    lv.memory = 8192
    if not RUBY_PLATFORM.downcase.include?("mswin")
      lv.cpus = `awk "/^processor/ {++n} END {print n}" /proc/cpuinfo 2> /dev/null || sh -c 'sysctl hw.logicalcpu 2> /dev/null || echo ": 2"' | awk \'{print \$2}\' `.chomp
    end

54 55
    override.vm.synced_folder ".", "/vagrant", type: "nfs"
    override.vm.synced_folder "../..", "/opt/stack/designate", type: "nfs"
56 57

    if File.directory?("../../../python-designateclient")
58
      override.vm.synced_folder "../../../python-designateclient", "/opt/stack/python-designateclient", type: "nfs"
59 60
    end

61 62 63 64
    if File.directory?("../../../designate-dashboard")
      override.vm.synced_folder "../../../designate-dashboard", "/opt/stack/designate-dashboard", type: "nfs"
    end

65 66 67 68
    if File.directory?("../../../designate-tempest-plugin")
      override.vm.synced_folder "../../../designate-tempest-plugin", "/opt/stack/designate-tempest-plugin", type: "nfs"
    end

69 70 71 72 73 74 75 76 77 78
    if File.directory?("../../../devstack")
      override.vm.synced_folder "../../../devstack", "/home/vagrant/devstack", type: "nfs"
    end

    if File.directory?("../../../tempest")
      override.vm.synced_folder "../../../tempest", "/opt/stack/tempest", type: "nfs"
    end

    if File.directory?("../../../rally")
      override.vm.synced_folder "../../../rally", "/opt/stack/rally", type: "nfs"
79
    end
80 81 82 83 84
  end

  $script = <<SCRIPT
set -e

85 86 87
# Fixup permissions on /opt/stack/
sudo chown vagrant:vagrant /opt/stack/

88 89 90 91 92 93 94 95 96 97
# Copy over git config
cat << EOF > /home/vagrant/.gitconfig
#{GITCONFIG}
EOF

# Clone DevStack
if [ ! -d "/home/vagrant/devstack" ]; then
    git clone https://git.openstack.org/openstack-dev/devstack.git /home/vagrant/devstack
fi

98
# Install Vagrant local.conf sample
99
cd /opt/stack/designate/contrib/vagrant
100

101 102
if [ ! -f "/home/vagrant/devstack/local.conf" ]; then
    cp local.conf /home/vagrant/devstack/local.conf
103 104
fi

105
# Link in any Rally Plugins
106 107 108
mkdir /home/vagrant/.rally
ln -s /opt/stack/designate/rally-scenarios/plugins /home/vagrant/.rally/plugins

109 110
SCRIPT

111
  config.vm.define "ubuntu", primary: true do |ubuntu|
112
    ubuntu.vm.box = "ubuntu/trusty64"
113 114 115 116

    ubuntu.vm.network :private_network, ip: "192.168.27.100"

    ubuntu.vm.provision :shell, :privileged => true, :inline => "DEBIAN_FRONTEND=noninteractive apt-get update"
117
    ubuntu.vm.provision :shell, :privileged => true, :inline => "DEBIAN_FRONTEND=noninteractive apt-get install --yes git lvm2"
118 119 120 121

    ubuntu.vm.provision :shell, :privileged => false, :inline => $script
  end

122
  config.vm.define "fedora", autostart: false do |fedora|
123 124 125 126 127
    fedora.vm.box = "box-cutter/fedora20"

    fedora.vm.network :private_network, ip: "192.168.27.101"

    fedora.vm.provision :shell, :privileged => true, :inline => "yum update -y vim-minimal" # RH Bug 1066983
128
    fedora.vm.provision :shell, :privileged => true, :inline => "yum install -y git-core"
129 130 131 132

    fedora.vm.provision :shell, :privileged => false, :inline => $script
  end
end