-
Notifications
You must be signed in to change notification settings - Fork 4
/
Vagrantfile
108 lines (86 loc) · 3.54 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require File.join(File.dirname(__FILE__), 'config', 'version')
VG_REPO = 'xparak'.freeze
VG_BOX = 'opennebula'.freeze
VG_BOX_VER = '5.4.0.build.1'.freeze
VM_SIZE = {
small: { cpus: 1, memory: 1024 },
large: { cpus: 2, memory: 2048 }
}.freeze
ROCCI_SERVER_DIR = '/opt/rOCCI-server'.freeze
ONE_ADDR = '192.168.50.2'.freeze
ROCCI_SERVER_ADDR = '192.168.50.5'.freeze
Vagrant.configure('2') do |config|
config.vm.define 'one', primary: true do |one|
one.vm.box = "#{VG_REPO}/#{VG_BOX}"
one.vm.box_version = VG_BOX_VER
one.vm.network 'forwarded_port', guest: 2633, host: 2633, host_ip: '127.0.0.1' # XML-RPC2
one.vm.network 'forwarded_port', guest: 9869, host: 9869, host_ip: '127.0.0.1' # GUI
one.vm.network 'private_network', ip: ONE_ADDR
one.vm.provider 'virtualbox' do |vb|
vb.name = "rocci-server_#{VG_BOX}-#{VG_BOX_VER}_sandbox"
vb.linked_clone = true
vb.gui = false
vb.cpus = VM_SIZE[:large][:cpus]
vb.memory = VM_SIZE[:large][:memory]
end
one.vm.provision 'shell', inline: <<-SHELL
ONE_HOME="/home/vagrant/.one/"
mkdir -p $ONE_HOME
cp /var/lib/one/.one/one_auth $ONE_HOME
chown -R vagrant:vagrant $ONE_HOME
SHELL
one.vm.provision 'shell', privileged: false, path: 'examples/opennebula/setup.sh'
end
config.vm.define 'rocci-server', autostart: false do |rocci_server|
rocci_server.vm.box = 'centos/7'
rocci_server.vm.network 'forwarded_port', guest: 3000, host: 3000, host_ip: '127.0.0.1' # REST
rocci_server.vm.network 'private_network', ip: ROCCI_SERVER_ADDR
rocci_server.vm.provider 'virtualbox' do |vb|
vb.name = "rocci-server-#{ROCCIServer::VERSION}"
vb.linked_clone = true
vb.gui = false
vb.cpus = VM_SIZE[:small][:cpus]
vb.memory = VM_SIZE[:small][:memory]
end
rocci_server.vm.provision 'shell', inline: <<-SHELL
yum install -y -q curl gcc zlib-devel git patch libyaml-devel autoconf gcc-c++ \
readline-devel libffi-devel openssl-devel automake libtool bison \
sqlite-devel memcached
systemctl enable memcached
systemctl start memcached
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable
usermod -a -G rvm vagrant
source /etc/profile.d/rvm.sh
rvm autolibs enable
rvm install 2.4.2
rvm 2.4.2 do gem install bundler
SHELL
rocci_server.vm.provision 'shell', inline: <<-SHELL
SERVER_DIR="#{ROCCI_SERVER_DIR}"
if [ -d "$SERVER_DIR" ] ; then
rm -rf $SERVER_DIR
fi
cp -Rp /vagrant $SERVER_DIR
chown -R vagrant:vagrant $SERVER_DIR
SHELL
rocci_server.vm.provision 'shell', privileged: false, inline: <<-SHELL
SERVER_DIR="#{ROCCI_SERVER_DIR}"
source /etc/profile.d/rvm.sh
cd $SERVER_DIR
rvm 2.4.2 do bundle install --deployment --without development test
if [ "x#{ENV['ROCCI_SERVER_INTEGRATION_ONE']}" = "xyes" ] ; then
export ROCCI_SERVER_BACKEND=opennebula
export ROCCI_SERVER_OPENNEBULA_ENDPOINT=http://#{ONE_ADDR}:2633/RPC2
rvm 2.4.2 do bundle exec bin/oneresource create --endpoint $ROCCI_SERVER_OPENNEBULA_ENDPOINT
fi
export RAILS_ENV=production
export HOST=0.0.0.0
export SECRET_KEY_BASE=a271402df66e152767d7b2149b8773adf242401eb8000e02a55a5d452fe2e47f7cf05969b8b77d1acb6319c9286e13ea3311b3e180115e9327482b5ecfa2f353
rvm 2.4.2 do bundle exec puma --daemon
sleep 5
SHELL
end
end