-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
191 lines (168 loc) · 6.95 KB
/
Vagrantfile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
def base_net_config
base_config = {
use_dhcp_assigned_default_route: true
}
if (ENV.keys & ["VAGRANT_KVM_BRIDGE", "VAGRANT_VBOX_BRIDGE"]).empty?
if ENV.include? "VAGRANT_DHCP"
# Use dhcp if VAGRANT_DHCP is set. This only applies to NAT networking, as
# bridged networking uses type: bridged (even though the virtual interface still
# gets its IP from dhcp). If not using dhcp, the VM will use the 192.168.77.77 IP
base_config[:type] = "dhcp"
else
base_config[:ip] = "192.168.77.77"
end
end
base_config
end
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
# Create port forward mappings
# These are only required when using private (NAT) networking, and want
# VM access from a client not on the VM host
#
# config.vm.network "forwarded_port", guest: 80, host: 80
# config.vm.network "forwarded_port", guest: 443, host: 443
# config.vm.network "forwarded_port", guest: 4443, host: 4443
# config.vm.network "forwarded_port", guest: 8501, host: 8501
vm_memory = ENV.fetch('VM_MEMORY', 10 * 1024).to_i
vm_cpus = ENV.fetch('VM_CPUS', 4).to_i
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.provider "virtualbox" do |vb, override|
# Need to shorten the URL for Windows' sake
override.vm.box = "https://cf-opensusefs2.s3.amazonaws.com/vagrant/scf-virtualbox-v2.0.9.box"
vb_net_config = base_net_config
if ENV.include? "VAGRANT_VBOX_BRIDGE"
vb_net_config[:bridge] = ENV.fetch("VAGRANT_VBOX_BRIDGE")
override.vm.network "public_network", vb_net_config
else
override.vm.network "private_network", vb_net_config
end
# Customize the amount of memory on the VM:
vb.memory = vm_memory.to_s
vb.cpus = vm_cpus
# If you need to debug stuff
# vb.gui = true
vb.customize ['modifyvm', :id, '--paravirtprovider', 'minimal']
# https://github.com/mitchellh/vagrant/issues/351
override.vm.synced_folder ".fissile/.bosh", "/home/vagrant/.bosh", type: "nfs"
override.vm.synced_folder ".", "/home/vagrant/scf", type: "nfs"
end
# Currently not built for vmware_fusion
# config.vm.provider "vmware_fusion" do |vb, override|
# override.vm.box="https://cf-opensusefs2.s3.amazonaws.com/vagrant/scf-vmware-v2.0.4.box"
#
# # Customize the amount of memory on the VM:
# vb.memory = vm_memory.to_s
# vb.cpus = vm_cpus
# # If you need to debug stuff
# # vb.gui = true
#
# # `vmrun getGuestIPAddress` often returns the address of the docker0 bridge instead of eth0 :(
# vb.enable_vmrun_ip_lookup = false
#
# # Disable default synced folder
# config.vm.synced_folder ".", "/vagrant", disabled: true
#
# # Enable HGFS
# vb.vmx["isolation.tools.hgfs.disable"] = "FALSE"
#
# # Must be equal to the total number of shares
# vb.vmx["sharedFolder.maxnum"] = "2"
#
# # Configure shared folders
# VMwareHacks.configure_shares(vb)
# end
# Currently not built for vmware_workstation
# config.vm.provider "vmware_workstation" do |vb, override|
# override.vm.box="https://cf-opensusefs2.s3.amazonaws.com/vagrant/scf-vmware-v2.0.4.box"
#
# # Customize the amount of memory on the VM:
# vb.memory = vm_memory.to_s
# vb.cpus = vm_cpus
# # If you need to debug stuff
# # vb.gui = true
#
# # Disable default synced folder
# config.vm.synced_folder ".", "/vagrant", disabled: true
#
# # Enable HGFS
# vb.vmx["isolation.tools.hgfs.disable"] = "FALSE"
#
# # Must be equal to the total number of shares
# vb.vmx["sharedFolder.maxnum"] = "2"
#
# # Configure shared folders
# VMwareHacks.configure_shares(vb)
# end
config.vm.provider "libvirt" do |libvirt, override|
override.vm.box = "https://cf-opensusefs2.s3.amazonaws.com/vagrant/scf-libvirt-v2.0.9.box"
libvirt.driver = "kvm"
libvirt_net_config = base_net_config
libvirt_net_config[:nic_model_type] = "virtio"
if ENV.include? "VAGRANT_KVM_BRIDGE"
libvirt_net_config[:dev] = ENV["VAGRANT_KVM_BRIDGE"]
libvirt_net_config[:type] = "bridge"
override.vm.network "public_network", libvirt_net_config
else
override.vm.network "private_network", libvirt_net_config
end
# Allow downloading boxes from sites with self-signed certs
libvirt.memory = vm_memory
libvirt.cpus = vm_cpus
override.vm.synced_folder ".fissile/.bosh", "/home/vagrant/.bosh", type: "nfs"
override.vm.synced_folder ".", "/home/vagrant/scf", type: "nfs"
end
config.vm.provision "shell", privileged: true, env: ENV.select { |e|
%w(http_proxy https_proxy no_proxy).include? e.downcase
}, path: "bin/common/write_proxy_vars_to_environment.sh"
# set up direnv so we can pick up fissile configuration
config.vm.provision "shell", privileged: false, inline: <<-SHELL
set -o errexit -o nounset
mkdir -p ${HOME}/bin
wget -O ${HOME}/bin/direnv --no-verbose \
https://github.com/direnv/direnv/releases/download/v2.11.3/direnv.linux-amd64
chmod a+x ${HOME}/bin/direnv
echo 'eval "$(${HOME}/bin/direnv hook bash)"' >> ${HOME}/.bashrc
ln -s ${HOME}/scf/bin/dev/vagrant-envrc ${HOME}/.envrc
${HOME}/bin/direnv allow ${HOME}
${HOME}/bin/direnv allow ${HOME}/scf
SHELL
# Install common and dev tools
config.vm.provision :shell, privileged: true, inline: <<-SHELL
set -o errexit -o xtrace -o verbose
# Get proxy configuration here
export HOME=/home/vagrant
export PATH=$PATH:/home/vagrant/bin
export SCF_BIN_DIR=/usr/local/bin
cd "${HOME}/scf"
bash ${HOME}/scf/bin/common/install_tools.sh
direnv exec ${HOME}/scf/bin/dev/install_tools.sh
SHELL
# Set up the storage class
config.vm.provision :shell, privileged: false, inline: <<-SHELL
if ! kubectl get storageclass persistent 2>/dev/null ; then
perl -p -e '[email protected]/[email protected]/v1@g' \
"${HOME}/scf/src/uaa-fissile-release/kube-test/storage-class-host-path.yml" | \
kubectl create -f -
fi
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
set -o errexit
echo 'if test -e /mnt/hgfs ; then /mnt/hgfs/scf/bin/dev/setup_vmware_mounts.sh ; fi' >> .profile
echo 'export PATH=$PATH:/home/vagrant/scf/container-host-files/opt/hcf/bin/' >> .profile
echo 'test -f /home/vagrant/scf/personal-setup && . /home/vagrant/scf/personal-setup' >> .profile
echo -e '\nexport HISTFILE=/home/vagrant/scf/output/.bash_history' >> .profile
# Check that the cluster is reasonable
/home/vagrant/scf/bin/dev/kube-ready-state-check.sh
direnv exec /home/vagrant/scf make -C /home/vagrant/scf copy-compile-cache
echo -e "\n\nAll done - you can \e[1;96mvagrant ssh\e[0m\n\n"
SHELL
end