|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | +# |
| 4 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 5 | +# or more contributor license agreements. See the NOTICE file |
| 6 | +# distributed with this work for additional information |
| 7 | +# regarding copyright ownership. The ASF licenses this file |
| 8 | +# to you under the Apache License, Version 2.0 (the |
| 9 | +# "License"); you may not use this file except in compliance |
| 10 | +# with the License. You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, |
| 15 | +# software distributed under the License is distributed on an |
| 16 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | +# KIND, either express or implied. See the License for the |
| 18 | +# specific language governing permissions and limitations |
| 19 | +# under the License. |
| 20 | +# |
| 21 | + |
| 22 | +VAGRANTFILE_API_VERSION = '2' |
| 23 | + |
| 24 | +Vagrant.require_version '>= 1.5.0' |
| 25 | + |
| 26 | +unless Vagrant.has_plugin?('vagrant-berkshelf') |
| 27 | + raise 'vagrant-berkshelf is not installed!' |
| 28 | +end |
| 29 | + |
| 30 | +unless Vagrant.has_plugin?('vagrant-omnibus') |
| 31 | + raise 'vagrant-omnibus is not installed!' |
| 32 | +end |
| 33 | + |
| 34 | +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') |
| 35 | + |
| 36 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 37 | + |
| 38 | + config.vm.define 'xenserver' do |xenserver| |
| 39 | + xenserver.vm.box = 'duffy/xenserver' |
| 40 | + |
| 41 | + # Public Network (IP address is ignored.) |
| 42 | + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.23.10' |
| 43 | + |
| 44 | + # Guest Network (IP address is ignored.) |
| 45 | + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.24.10' |
| 46 | + |
| 47 | + # Configure Interfaces |
| 48 | + |
| 49 | + ## Configure Management Interface |
| 50 | + xenserver.vm.provision 'shell' do |s| |
| 51 | + s.path = xenserver_networking_script |
| 52 | + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) |
| 53 | + end |
| 54 | + |
| 55 | + ## Configure Public Interface |
| 56 | + xenserver.vm.provision 'shell' do |s| |
| 57 | + s.path = xenserver_networking_script |
| 58 | + s.args = %w(eth2 na na PUBLIC) |
| 59 | + end |
| 60 | + |
| 61 | + ## Configure Guest Interface |
| 62 | + xenserver.vm.provision 'shell' do |s| |
| 63 | + s.path = xenserver_networking_script |
| 64 | + s.args = %w(eth3 na na GUEST) |
| 65 | + end |
| 66 | + |
| 67 | + ## Tweak kernel |
| 68 | + xenserver.vm.provision "shell", inline: "sed -i -e 's/net.bridge.bridge-nf-call-iptables = 1/net.bridge.bridge-nf-call-iptables = 0/g' -e 's/net.bridge.bridge-nf-call-arptables = 1/net.bridge.bridge-nf-call-arptables = 0/g' /etc/sysctl.conf && /sbin/sysctl -p /etc/sysctl.conf" |
| 69 | + |
| 70 | + ## Map host only networks and the adapters |
| 71 | + xenserver.vm.provider 'virtualbox' do |v| |
| 72 | + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] |
| 73 | + v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all'] |
| 74 | + v.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all'] |
| 75 | + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] |
| 76 | + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] |
| 77 | + v.customize ['modifyvm', :id, '--hostonlyadapter4', 'vboxnet2'] |
| 78 | + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] |
| 79 | + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] |
| 80 | + v.customize ["modifyvm", :id, '--nictype4', 'Am79C973'] |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + config.vm.define 'management' do |management| |
| 85 | + management.vm.box = 'chef/centos-6.5' |
| 86 | + |
| 87 | + # Configure management interface |
| 88 | + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' |
| 89 | + |
| 90 | + # Configure public interface |
| 91 | + management.vm.network :private_network, :auto_config => true, :ip => '192.168.23.5' |
| 92 | + |
| 93 | + # Port forward MySQL |
| 94 | + management.vm.network 'forwarded_port', guest: 3306, host: 3306 |
| 95 | + |
| 96 | + management.vm.provider 'virtualbox' do |v| |
| 97 | + v.customize ['modifyvm', :id, '--memory', 512] |
| 98 | + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] |
| 99 | + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] |
| 100 | + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] |
| 101 | + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] |
| 102 | + end |
| 103 | + |
| 104 | + management.omnibus.chef_version = "11.16.4" |
| 105 | + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') |
| 106 | + management.berkshelf.enabled = true |
| 107 | + |
| 108 | + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) |
| 109 | + |
| 110 | + management.vm.provision 'chef_solo' do |chef| |
| 111 | + chef.run_list = CHEF_CONFIGURATION.delete('run_list') |
| 112 | + chef.json = CHEF_CONFIGURATION |
| 113 | + end |
| 114 | + end |
| 115 | +end |
0 commit comments