forked from StackStorm/st2-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
87 lines (76 loc) · 2.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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
VIRTUAL_MACHINES = {
:trusty => {
:hostname => 'st2-packages-trusty',
:box => 'ubuntu/trusty64',
:ip => '192.168.16.20',
},
:xenial => {
:hostname => 'st2-packages-xenial',
:box => 'ubuntu/xenial64',
:ip => '192.168.16.21',
},
:bionic=> {
:hostname => 'st2-packages-bionic',
:box => 'ubuntu/bionic64',
:ip => '192.168.16.23',
},
:el7 => {
:hostname => 'st2-packages-el7',
:box => 'centos/7',
:ip => '192.168.16.22',
},
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
VIRTUAL_MACHINES.each do |name, cfg|
config.vm.define name do |vm_config|
vm_config.vm.hostname = cfg[:hostname]
vm_config.vm.box = cfg[:box]
# Give VM access to all CPU cores on the host
# docker-compose & rake build can benefit from more CPUs
host_os = RbConfig::CONFIG['host_os']
if host_os =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
elsif host_os =~ /linux/
cpus = `nproc`.to_i
else # sorry Windows folks, I can't help you
cpus = 2
end
# Box Specifications
vm_config.vm.provider :virtualbox do |vb|
vb.name = "#{cfg[:hostname]}"
# NOTE: With 2048MB, system slows due to kswapd. Recommend at least 4096MB.
vb.customize ['modifyvm', :id, '--memory', '4096']
vb.customize ["modifyvm", :id, "--cpus", cpus]
# Docker connection fix
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
end
# Sync folder using NFS
# vm_config.vm.synced_folder '.', '/vagrant', nfs: true
# Configure a private network
vm_config.vm.network "private_network", ip: "#{cfg[:ip]}"
# Public (bridged) network may come handy for external access to VM (e.g. sensor development)
# See https://www.vagrantup.com/docs/networking/public_network.html
# st2.vm.network "public_network", bridge: 'en0: Wi-Fi (AirPort)'
# Install docker-engine
vm_config.vm.provision :docker
vm_config.vm.provision 'shell', path: 'scripts/setup-vagrant.sh', privileged: false, env: {
"ST2_TARGET" => "#{name}",
"ST2_USER" => ENV['ST2USER'] ? ENV['ST2USER'] : 'st2admin',
"ST2_PASSWORD" => ENV['ST2PASSWORD'] ? ENV['ST2PASSWORD'] : 'st2admin',
"ST2_PACKAGES" => ENV['ST2_PACKAGES'] ? ENV['ST2_PACKAGES'] : 'st2 st2mistral',
"ST2_INSTALL" => ENV['ST2_INSTALL'] ? ENV['ST2_INSTALL'] : 'yes',
"ST2_VERIFY" => ENV['ST2_VERIFY'] ? ENV['ST2_VERIFY'] : 'yes',
"ST2_GITURL" => ENV['ST2_GITURL'],
"ST2_GITREV" => ENV['ST2_GITREV'],
"ST2MISTRAL_GITURL" => ENV['ST2MISTRAL_GITURL'],
"ST2MISTRAL_GITREV" => ENV['ST2MISTRAL_GITREV'],
}
end
end
end