forked from kpath/Vagrant-CRS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
137 lines (108 loc) · 4.33 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
DB_PRIVATE_IP = "192.168.70.4"
ATG_PRIVATE_IP = "192.168.70.5"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :db12c do |db12c_config|
db12c_config.vm.box = "opscode-centos-6.6"
db12c_config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box"
# change memory size
db12c_config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
# static IP so we can configure machines to talk to each other
db12c_config.vm.network "private_network", ip: DB_PRIVATE_IP
# provision
db12c_config.vm.provision "shell" do |s|
s.path = "scripts/db12c/provision.sh"
s.args = ENV['DB12C_PROVISION_ARGS']
end
end
# ============================
config.vm.define :db11g do |db11g_config|
db11g_config.vm.box = "opscode-centos-6.6"
db11g_config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box"
# change memory size
db11g_config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
# static IP so we can configure machines to talk to each other
db11g_config.vm.network "private_network", ip: DB_PRIVATE_IP
# provision
db11g_config.vm.provision "shell" do |s|
s.path = "scripts/db11g/provision.sh"
s.args = ENV['DB11G_PROVISION_ARGS']
end
end
# ==============================
config.vm.define :atg do |atg_config|
atg_config.vm.box = "opscode-centos-6.6"
atg_config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box"
# change memory size
atg_config.vm.provider "virtualbox" do |v|
v.memory = 6144
end
# static IP so we can configure machines to talk to each other
atg_config.vm.network "private_network", ip: ATG_PRIVATE_IP
# provision
atg_config.vm.provision "shell" do |s|
s.path = "scripts/atg/provision.sh"
s.args = ENV['ATG_PROVISION_ARGS']
end
end
end
module UpdateCentOSKernel
class UpdateCentOSKernelPlugin < Vagrant.plugin('2')
name 'update_centos_kernel_plugin'
# update yum after first boot when provisioning
action_hook(:update_yum, :machine_action_up) do |hook|
hook.after(VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions, UpdateCentOSKernel::Middleware::KernelUpdater)
end
end
module Middleware
class KernelUpdater
@@rebooted = {};
def initialize(app, env)
@app = app
end
def call(env)
@env = env
@vm = env[:machine]
@ui = env[:ui]
self.update_kernel()
end
def update_kernel()
if !@@rebooted[@vm.id]
@@rebooted[@vm.id] = true
@ui.info 'Updating kernel'
@vm.communicate.sudo('yum install -y kernel kernel-devel') do |type, data|
if type == :stderr
@ui.error(data);
else
@ui.info(data);
end
end
self.reboot()
end
end
def reboot()
@ui.info('Rebooting after updating kernel')
simle_reboot = Vagrant::Action::Builder.new.tap do |b|
b.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :poweroff, :running do |env2, b2|
if !env2[:result]
b2.use VagrantPlugins::ProviderVirtualBox::Action::ForcedHalt
end
end
b.use VagrantPlugins::ProviderVirtualBox::Action::Boot
if defined?(Vagrant::Action::Builtin::WaitForCommunicator)
b.use Vagrant::Action::Builtin::WaitForCommunicator, [:starting, :running]
end
b.use VagrantVbguest::Middleware
end
@env[:action_runner].run(simle_reboot, @env)
end
end
end
end