corl 0.4.20 → 0.4.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/corl.gemspec +4 -3
- data/lib/CORL/machine/vagrant.rb +14 -69
- data/lib/core/facade.rb +7 -0
- data/lib/core/mixin/machine/ssh.rb +118 -0
- data/lib/core/mod/fog_aws_server.rb +10 -4
- data/lib/core/mod/fog_rackspace_server.rb +1 -0
- data/lib/core/plugin/fog_machine.rb +27 -106
- data/lib/core/plugin/machine.rb +1 -1
- data/lib/core/plugin/node.rb +17 -11
- data/lib/core/plugin/provisioner.rb +2 -2
- data/lib/core/vagrant/action.rb +12 -9
- data/lib/core/vagrant/provisioner/config.rb +7 -3
- data/lib/core/vagrant/provisioner/provisioner.rb +3 -1
- data/lib/corl.rb +13 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3bb80a650eb209623ead506dd69a51306c1fcf0
|
4
|
+
data.tar.gz: e41e127547eb7677cf335aa661301b11ffcb690e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c37715b7116f293ab7d8d2f96610f0e17d7a8d136cce335d06a2b1f540047b7ed2b340643ed998ec02fca54122d8925ffe8af665933e7f177ddd363d554ccc6
|
7
|
+
data.tar.gz: a07956638bdcb9915e2152158417ef1b073b7eae676f57a2b87dc97a2fe0864b79f88c7337589dfbbdc219740ed570cbbc8baef51e13fbdf65ad31ad7790b840
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.21
|
data/corl.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: corl 0.4.
|
5
|
+
# stub: corl 0.4.21 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "corl"
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.21"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Adrian Webb"]
|
14
|
-
s.date = "2014-04-
|
14
|
+
s.date = "2014-04-28"
|
15
15
|
s.description = "Framework that provides a simple foundation for growing organically in the cloud"
|
16
16
|
s.email = "adrian.webb@coralnexus.com"
|
17
17
|
s.executables = ["corl"]
|
@@ -83,6 +83,7 @@ Gem::Specification.new do |s|
|
|
83
83
|
"lib/core/facade.rb",
|
84
84
|
"lib/core/mixin/action/keypair.rb",
|
85
85
|
"lib/core/mixin/lookup.rb",
|
86
|
+
"lib/core/mixin/machine/ssh.rb",
|
86
87
|
"lib/core/mixin/macro/network_settings.rb",
|
87
88
|
"lib/core/mod/facter_loader.rb",
|
88
89
|
"lib/core/mod/fog_aws_server.rb",
|
data/lib/CORL/machine/vagrant.rb
CHANGED
@@ -3,6 +3,10 @@ module CORL
|
|
3
3
|
module Machine
|
4
4
|
class Vagrant < CORL.plugin_class(:machine)
|
5
5
|
|
6
|
+
include Mixin::Machine::SSH
|
7
|
+
|
8
|
+
#---
|
9
|
+
|
6
10
|
@@lock = Mutex.new
|
7
11
|
|
8
12
|
#-----------------------------------------------------------------------------
|
@@ -101,56 +105,25 @@ class Vagrant < CORL.plugin_class(:machine)
|
|
101
105
|
|
102
106
|
#---
|
103
107
|
|
104
|
-
def download(remote_path, local_path, options = {})
|
108
|
+
def download(remote_path, local_path, options = {}, &code)
|
105
109
|
super do |config, success|
|
106
|
-
|
107
|
-
if init_ssh_session
|
108
|
-
Util::SSH.download(node.public_ip, node.user, remote_path, local_path, config.export) do |name, received, total|
|
109
|
-
yield(name, received, total) if block_given?
|
110
|
-
end
|
111
|
-
true
|
112
|
-
else
|
113
|
-
false
|
114
|
-
end
|
115
|
-
rescue Exception => error
|
116
|
-
ui.error(error.message)
|
117
|
-
false
|
118
|
-
end
|
110
|
+
ssh_download(remote_path, local_path, config, &code)
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
122
114
|
#---
|
123
115
|
|
124
|
-
def upload(local_path, remote_path, options = {})
|
116
|
+
def upload(local_path, remote_path, options = {}, &code)
|
125
117
|
super do |config, success|
|
126
|
-
|
127
|
-
if init_ssh_session
|
128
|
-
Util::SSH.upload(node.public_ip, node.user, local_path, remote_path, config.export) do |name, sent, total|
|
129
|
-
yield(name, sent, total) if block_given?
|
130
|
-
end
|
131
|
-
true
|
132
|
-
else
|
133
|
-
false
|
134
|
-
end
|
135
|
-
rescue Exception => error
|
136
|
-
ui.error(error.message)
|
137
|
-
false
|
138
|
-
end
|
118
|
+
ssh_upload(local_path, remote_path, config, &code)
|
139
119
|
end
|
140
120
|
end
|
141
121
|
|
142
122
|
#---
|
143
123
|
|
144
|
-
def exec(commands, options = {})
|
145
|
-
super do |config
|
146
|
-
|
147
|
-
results = Util::SSH.exec(node.public_ip, node.user, commands) do |type, command, data|
|
148
|
-
yield(type, command, data) if block_given?
|
149
|
-
end
|
150
|
-
else
|
151
|
-
results = nil
|
152
|
-
end
|
153
|
-
results
|
124
|
+
def exec(commands, options = {}, &code)
|
125
|
+
super do |config|
|
126
|
+
ssh_exec(commands, config, &code)
|
154
127
|
end
|
155
128
|
end
|
156
129
|
|
@@ -158,7 +131,7 @@ class Vagrant < CORL.plugin_class(:machine)
|
|
158
131
|
|
159
132
|
def terminal(user, options = {})
|
160
133
|
super do |config|
|
161
|
-
|
134
|
+
ssh_terminal(user, config)
|
162
135
|
end
|
163
136
|
end
|
164
137
|
|
@@ -203,7 +176,7 @@ class Vagrant < CORL.plugin_class(:machine)
|
|
203
176
|
load
|
204
177
|
end
|
205
178
|
|
206
|
-
rescue
|
179
|
+
rescue => error
|
207
180
|
ui.error(error.message)
|
208
181
|
success = false
|
209
182
|
end
|
@@ -332,7 +305,7 @@ class Vagrant < CORL.plugin_class(:machine)
|
|
332
305
|
|
333
306
|
server.send(:action, action.to_sym, params)
|
334
307
|
|
335
|
-
rescue
|
308
|
+
rescue => error
|
336
309
|
ui.error(error)
|
337
310
|
ui.error(Util::Data.to_yaml(error.backtrace))
|
338
311
|
success = false
|
@@ -341,34 +314,6 @@ class Vagrant < CORL.plugin_class(:machine)
|
|
341
314
|
success
|
342
315
|
end
|
343
316
|
protected :run
|
344
|
-
|
345
|
-
#---
|
346
|
-
|
347
|
-
def init_ssh_session(reset = false, tries = 5, sleep_secs = 5)
|
348
|
-
success = true
|
349
|
-
|
350
|
-
begin
|
351
|
-
Util::SSH.session(node.public_ip, node.user, node.ssh_port, node.private_key, reset)
|
352
|
-
|
353
|
-
rescue Exception => error
|
354
|
-
if tries > 1
|
355
|
-
sleep(sleep_secs)
|
356
|
-
|
357
|
-
tries -= 1
|
358
|
-
reset = true
|
359
|
-
retry
|
360
|
-
else
|
361
|
-
success = false
|
362
|
-
end
|
363
|
-
end
|
364
|
-
success
|
365
|
-
end
|
366
|
-
|
367
|
-
#---
|
368
|
-
|
369
|
-
def close_ssh_session
|
370
|
-
Util::SSH.close_session(node.public_ip, node.user)
|
371
|
-
end
|
372
317
|
end
|
373
318
|
end
|
374
319
|
end
|
data/lib/core/facade.rb
CHANGED
@@ -22,9 +22,16 @@ module Facade
|
|
22
22
|
|
23
23
|
#---
|
24
24
|
|
25
|
+
@@vagrant_config_loaded = false
|
26
|
+
|
27
|
+
def vagrant_config_loaded?
|
28
|
+
@@vagrant_config_loaded
|
29
|
+
end
|
30
|
+
|
25
31
|
def vagrant_config(directory, config, &code)
|
26
32
|
require File.join(File.dirname(__FILE__), 'vagrant', 'config.rb')
|
27
33
|
Vagrant::Config.register(directory, config, &code)
|
34
|
+
@@vagrant_config_loaded = true
|
28
35
|
end
|
29
36
|
|
30
37
|
#-----------------------------------------------------------------------------
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module CORL
|
2
|
+
module Mixin
|
3
|
+
module Machine
|
4
|
+
module SSH
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# SSH Operations
|
8
|
+
|
9
|
+
def init_ssh_session(reset = false, tries = 5, sleep_secs = 5)
|
10
|
+
ssh_wait_for_ready
|
11
|
+
|
12
|
+
success = true
|
13
|
+
|
14
|
+
begin
|
15
|
+
Util::SSH.session(node.public_ip, node.user, node.ssh_port, node.private_key, reset)
|
16
|
+
|
17
|
+
rescue Net::SSH::HostKeyMismatch => error
|
18
|
+
error.remember_host!
|
19
|
+
sleep 0.2
|
20
|
+
reset = true
|
21
|
+
retry
|
22
|
+
|
23
|
+
rescue Net::SSH::ConnectionTimeout, Net::SSH::Disconnect => error
|
24
|
+
if tries > 1
|
25
|
+
sleep(sleep_secs)
|
26
|
+
|
27
|
+
tries -= 1
|
28
|
+
reset = true
|
29
|
+
retry
|
30
|
+
else
|
31
|
+
success = false
|
32
|
+
end
|
33
|
+
|
34
|
+
rescue => error
|
35
|
+
ui.warn(error)
|
36
|
+
success = false
|
37
|
+
end
|
38
|
+
success
|
39
|
+
end
|
40
|
+
|
41
|
+
#---
|
42
|
+
|
43
|
+
def ssh_download(remote_path, local_path, options = {}, &code)
|
44
|
+
config = Config.ensure(options)
|
45
|
+
success = false
|
46
|
+
|
47
|
+
begin
|
48
|
+
if init_ssh_session
|
49
|
+
Util::SSH.download(node.public_ip, node.user, remote_path, local_path, config.export) do |name, received, total|
|
50
|
+
code.call(name, received, total) if code
|
51
|
+
end
|
52
|
+
success = true
|
53
|
+
end
|
54
|
+
rescue => error
|
55
|
+
ui.error(error.message)
|
56
|
+
end
|
57
|
+
|
58
|
+
success
|
59
|
+
end
|
60
|
+
|
61
|
+
#---
|
62
|
+
|
63
|
+
def ssh_upload(local_path, remote_path, options = {}, &code)
|
64
|
+
config = Config.ensure(options)
|
65
|
+
success = false
|
66
|
+
|
67
|
+
begin
|
68
|
+
if init_ssh_session
|
69
|
+
Util::SSH.upload(node.public_ip, node.user, local_path, remote_path, config.export) do |name, sent, total|
|
70
|
+
code.call(name, sent, total) if code
|
71
|
+
end
|
72
|
+
success = true
|
73
|
+
end
|
74
|
+
rescue => error
|
75
|
+
ui.error(error.message)
|
76
|
+
end
|
77
|
+
|
78
|
+
success
|
79
|
+
end
|
80
|
+
|
81
|
+
#---
|
82
|
+
|
83
|
+
def ssh_exec(commands, options = {}, &code)
|
84
|
+
config = Config.ensure(options)
|
85
|
+
results = nil
|
86
|
+
|
87
|
+
if commands
|
88
|
+
if init_ssh_session
|
89
|
+
results = Util::SSH.exec(node.public_ip, node.user, commands) do |type, command, data|
|
90
|
+
code.call(type, command, data) if code
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
results
|
95
|
+
end
|
96
|
+
|
97
|
+
#---
|
98
|
+
|
99
|
+
def close_ssh_session
|
100
|
+
Util::SSH.close_session(node.public_ip, node.user)
|
101
|
+
end
|
102
|
+
|
103
|
+
#---
|
104
|
+
|
105
|
+
def ssh_terminal(user, options = {})
|
106
|
+
Util::SSH.terminal(node.public_ip, user, Config.ensure(options).export)
|
107
|
+
end
|
108
|
+
|
109
|
+
#-----------------------------------------------------------------------------
|
110
|
+
# Utilities
|
111
|
+
|
112
|
+
def ssh_wait_for_ready
|
113
|
+
# Override in class if needed (see Fog Machine provider)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -22,13 +22,19 @@ class Server
|
|
22
22
|
Nucleon::Util::SSH.session(ssh_ip_address, username, ssh_port, private_key_path, true)
|
23
23
|
results = Nucleon::Util::SSH.exec(ssh_ip_address, username, commands)
|
24
24
|
|
25
|
-
rescue
|
25
|
+
rescue Net::SSH::HostKeyMismatch => error
|
26
|
+
error.remember_host!
|
27
|
+
sleep 0.2
|
28
|
+
reset = true
|
29
|
+
retry
|
30
|
+
|
31
|
+
rescue Net::SSH::ConnectionTimeout, Net::SSH::Disconnect => error
|
26
32
|
if tries > 1
|
27
|
-
sleep(sleep_secs)
|
33
|
+
sleep(sleep_secs)
|
34
|
+
|
28
35
|
tries -= 1
|
36
|
+
reset = true
|
29
37
|
retry
|
30
|
-
else
|
31
|
-
raise error
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -6,6 +6,8 @@ nucleon_require(File.dirname(__FILE__), :machine)
|
|
6
6
|
module CORL
|
7
7
|
module Machine
|
8
8
|
class Fog < CORL.plugin_class(:machine)
|
9
|
+
|
10
|
+
include Mixin::Machine::SSH
|
9
11
|
|
10
12
|
#-----------------------------------------------------------------------------
|
11
13
|
# Checks
|
@@ -135,10 +137,10 @@ class Fog < CORL.plugin_class(:machine)
|
|
135
137
|
|
136
138
|
#---
|
137
139
|
|
138
|
-
def create(options = {})
|
140
|
+
def create(options = {}, &code)
|
139
141
|
super do |config|
|
140
142
|
if compute
|
141
|
-
|
143
|
+
code.call(config) if code
|
142
144
|
myself.server = compute.servers.bootstrap(config.export)
|
143
145
|
end
|
144
146
|
myself.server ? true : false
|
@@ -147,64 +149,25 @@ class Fog < CORL.plugin_class(:machine)
|
|
147
149
|
|
148
150
|
#---
|
149
151
|
|
150
|
-
def download(remote_path, local_path, options = {})
|
152
|
+
def download(remote_path, local_path, options = {}, &code)
|
151
153
|
super do |config, success|
|
152
|
-
|
153
|
-
|
154
|
-
begin
|
155
|
-
if init_ssh_session(server)
|
156
|
-
Util::SSH.download(node.public_ip, node.user, remote_path, local_path, config.export) do |name, received, total|
|
157
|
-
yield(name, received, total) if block_given?
|
158
|
-
end
|
159
|
-
true
|
160
|
-
else
|
161
|
-
false
|
162
|
-
end
|
163
|
-
rescue Exception => error
|
164
|
-
ui.error(error.message)
|
165
|
-
false
|
166
|
-
end
|
154
|
+
ssh_download(remote_path, local_path, config, &code)
|
167
155
|
end
|
168
156
|
end
|
169
157
|
|
170
158
|
#---
|
171
159
|
|
172
|
-
def upload(local_path, remote_path, options = {})
|
160
|
+
def upload(local_path, remote_path, options = {}, &code)
|
173
161
|
super do |config, success|
|
174
|
-
|
175
|
-
|
176
|
-
begin
|
177
|
-
if init_ssh_session(server)
|
178
|
-
Util::SSH.upload(node.public_ip, node.user, local_path, remote_path, config.export) do |name, sent, total|
|
179
|
-
yield(name, sent, total) if block_given?
|
180
|
-
end
|
181
|
-
true
|
182
|
-
else
|
183
|
-
false
|
184
|
-
end
|
185
|
-
rescue Exception => error
|
186
|
-
ui.error(error.message)
|
187
|
-
false
|
188
|
-
end
|
162
|
+
ssh_upload(local_path, remote_path, config, &code)
|
189
163
|
end
|
190
164
|
end
|
191
165
|
|
192
166
|
#---
|
193
167
|
|
194
|
-
def exec(commands, options = {})
|
195
|
-
super do |config
|
196
|
-
|
197
|
-
logger.debug("Executing SSH commands ( #{commands.inspect} ) on machine #{plugin_name}")
|
198
|
-
|
199
|
-
if init_ssh_session(server)
|
200
|
-
results = Util::SSH.exec(node.public_ip, node.user, commands) do |type, command, data|
|
201
|
-
yield(type, command, data) if block_given?
|
202
|
-
end
|
203
|
-
else
|
204
|
-
results = nil
|
205
|
-
end
|
206
|
-
end
|
207
|
-
results
|
168
|
+
def exec(commands, options = {}, &code)
|
169
|
+
super do |config|
|
170
|
+
ssh_exec(commands, config, &code)
|
208
171
|
end
|
209
172
|
end
|
210
173
|
|
@@ -212,36 +175,27 @@ class Fog < CORL.plugin_class(:machine)
|
|
212
175
|
|
213
176
|
def terminal(user, options = {})
|
214
177
|
super do |config|
|
215
|
-
|
178
|
+
ssh_terminal(user, config)
|
216
179
|
end
|
217
180
|
end
|
218
181
|
|
219
182
|
#---
|
220
183
|
|
221
|
-
def reload(options = {})
|
184
|
+
def reload(options = {}, &code)
|
222
185
|
super do |config|
|
223
|
-
success =
|
224
|
-
if
|
225
|
-
success = block_given? ? yield(config) : true
|
226
|
-
success = init_ssh_session(server, true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
|
227
|
-
end
|
228
|
-
success
|
186
|
+
success = code ? code.call(config) : true
|
187
|
+
success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
|
229
188
|
end
|
230
189
|
end
|
231
190
|
|
232
191
|
#---
|
233
192
|
|
234
|
-
def create_image(options = {})
|
193
|
+
def create_image(options = {}, &code)
|
235
194
|
super do |config|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s)
|
241
|
-
success = yield(image_name, config, success) if block_given? # Implement in sub classes
|
242
|
-
success = init_ssh_session(server, true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
|
243
|
-
end
|
244
|
-
success
|
195
|
+
image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s)
|
196
|
+
|
197
|
+
success = code ? code.call(image_name, config, success) : true
|
198
|
+
success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
|
245
199
|
end
|
246
200
|
end
|
247
201
|
|
@@ -249,27 +203,18 @@ class Fog < CORL.plugin_class(:machine)
|
|
249
203
|
|
250
204
|
def stop(options = {})
|
251
205
|
super do |config|
|
252
|
-
success =
|
253
|
-
|
254
|
-
logger.debug("Stopping machine #{plugin_name}")
|
255
|
-
success = destroy(config.import({ :stop => true }))
|
256
|
-
else
|
257
|
-
success = false
|
258
|
-
end
|
259
|
-
success
|
206
|
+
success = false
|
207
|
+
success = destroy(config.import({ :stop => true })) if create_image(config)
|
260
208
|
end
|
261
209
|
end
|
262
210
|
|
263
211
|
#---
|
264
212
|
|
265
|
-
def destroy(options = {})
|
213
|
+
def destroy(options = {}, &code)
|
266
214
|
super do |config|
|
267
|
-
success =
|
268
|
-
if
|
269
|
-
|
270
|
-
success = server.destroy
|
271
|
-
success = yield(config) if success && block_given?
|
272
|
-
end
|
215
|
+
success = server.destroy
|
216
|
+
success = code.call(config) if success && code
|
217
|
+
|
273
218
|
close_ssh_session if success
|
274
219
|
success
|
275
220
|
end
|
@@ -278,32 +223,8 @@ class Fog < CORL.plugin_class(:machine)
|
|
278
223
|
#-----------------------------------------------------------------------------
|
279
224
|
# Utilities
|
280
225
|
|
281
|
-
def
|
226
|
+
def ssh_wait_for_ready
|
282
227
|
server.wait_for { ready? }
|
283
|
-
|
284
|
-
success = true
|
285
|
-
|
286
|
-
begin
|
287
|
-
Util::SSH.session(node.public_ip, node.user, node.ssh_port, node.private_key, reset)
|
288
|
-
|
289
|
-
rescue Exception => error
|
290
|
-
if tries > 1
|
291
|
-
sleep(sleep_secs)
|
292
|
-
|
293
|
-
tries -= 1
|
294
|
-
reset = true
|
295
|
-
retry
|
296
|
-
else
|
297
|
-
success = false
|
298
|
-
end
|
299
|
-
end
|
300
|
-
success
|
301
|
-
end
|
302
|
-
|
303
|
-
#---
|
304
|
-
|
305
|
-
def close_ssh_session
|
306
|
-
Util::SSH.close_session(node.public_ip, node.user)
|
307
228
|
end
|
308
229
|
end
|
309
230
|
end
|
data/lib/core/plugin/machine.rb
CHANGED
@@ -151,7 +151,7 @@ class Machine < CORL.plugin_class(:base)
|
|
151
151
|
results = []
|
152
152
|
|
153
153
|
if running?
|
154
|
-
logger.
|
154
|
+
logger.info("Executing commands ( #{commands.inspect} ) on machine #{plugin_name}")
|
155
155
|
config = Config.ensure(options)
|
156
156
|
results = yield(config, results) if block_given?
|
157
157
|
else
|
data/lib/core/plugin/node.rb
CHANGED
@@ -363,10 +363,10 @@ class Node < CORL.plugin_class(:base)
|
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
|
+
myself.build_time = Time.now.to_s if success
|
367
|
+
|
366
368
|
if success && config.delete(:save, true)
|
367
|
-
ui.success("Saving successful build")
|
368
|
-
|
369
|
-
myself.build_time = Time.now.to_s
|
369
|
+
ui.success("Saving successful build")
|
370
370
|
|
371
371
|
success = save(extended_config(:build, {
|
372
372
|
:message => config.get(:message, "Built #{plugin_provider} node: #{plugin_name}"),
|
@@ -611,15 +611,21 @@ class Node < CORL.plugin_class(:base)
|
|
611
611
|
end
|
612
612
|
|
613
613
|
if commands = config.get(:commands, nil)
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
614
|
+
begin
|
615
|
+
test = active_machine.exec(commands, config.export) do |type, command, data|
|
616
|
+
unless local?
|
617
|
+
if type == :error
|
618
|
+
alert(filter_output(type, data))
|
619
|
+
else
|
620
|
+
render(filter_output(type, data))
|
621
|
+
end
|
620
622
|
end
|
623
|
+
yield(:progress, { :type => type, :command => command, :data => data }) if block_given?
|
621
624
|
end
|
622
|
-
|
625
|
+
results = test if test
|
626
|
+
|
627
|
+
rescue Exception => error
|
628
|
+
default_error.append_errors(error.message)
|
623
629
|
end
|
624
630
|
else
|
625
631
|
default_error.append_errors("No execution command")
|
@@ -884,7 +890,7 @@ class Node < CORL.plugin_class(:base)
|
|
884
890
|
success = save(config) if success
|
885
891
|
|
886
892
|
if success
|
887
|
-
if
|
893
|
+
if config.get(:bootstrap, true) && bootstrap_script
|
888
894
|
result = command("HOSTNAME='#{hostname}' #{bootstrap_script}", { :as_admin => true }) do |op, data|
|
889
895
|
yield("bootstrap_#{op}".to_sym, data) if block_given?
|
890
896
|
data
|
@@ -107,7 +107,7 @@ class Provisioner < CORL.plugin_class(:base)
|
|
107
107
|
def build_locations(reset = false)
|
108
108
|
locations = cache_setting(:build_locations, {}, :hash)
|
109
109
|
build if reset || locations.empty?
|
110
|
-
cache_setting(:build_locations, {}, :hash)
|
110
|
+
symbol_map(cache_setting(:build_locations, {}, :hash))
|
111
111
|
end
|
112
112
|
|
113
113
|
#---
|
@@ -115,7 +115,7 @@ class Provisioner < CORL.plugin_class(:base)
|
|
115
115
|
def build_info(reset = false)
|
116
116
|
info = cache_setting(:build_info, {}, :hash)
|
117
117
|
build if reset || info.empty?
|
118
|
-
cache_setting(:build_info, {}, :hash)
|
118
|
+
symbol_map(cache_setting(:build_info, {}, :hash))
|
119
119
|
end
|
120
120
|
|
121
121
|
#---
|
data/lib/core/vagrant/action.rb
CHANGED
@@ -13,6 +13,17 @@ class BaseAction
|
|
13
13
|
@network = nil
|
14
14
|
@node = nil
|
15
15
|
@vm = nil
|
16
|
+
|
17
|
+
if @corl_config_loaded = ::CORL.vagrant_config_loaded?
|
18
|
+
# Hackish solution to ensure our code has access to Vagrant machines.
|
19
|
+
# This serves as a Vagrant VM manager.
|
20
|
+
::CORL::Vagrant.command = Command::Launcher.new([], @env)
|
21
|
+
|
22
|
+
if @network = ::CORL::Vagrant::Config.load_network(env[:root_path])
|
23
|
+
@vm = env[:machine]
|
24
|
+
@node = network.node(:vagrant, @vm.name) if @vm
|
25
|
+
end
|
26
|
+
end
|
16
27
|
end
|
17
28
|
|
18
29
|
#-----------------------------------------------------------------------------
|
@@ -24,15 +35,7 @@ class BaseAction
|
|
24
35
|
# Action execution
|
25
36
|
|
26
37
|
def call(env)
|
27
|
-
|
28
|
-
# This serves as a Vagrant VM manager.
|
29
|
-
::CORL::Vagrant.command = Command::Launcher.new([], @env)
|
30
|
-
|
31
|
-
if @network = ::CORL::Vagrant::Config.load_network(env[:root_path])
|
32
|
-
@vm = env[:machine]
|
33
|
-
@node = network.node(:vagrant, @vm.name) if @vm
|
34
|
-
yield if block_given? && @node
|
35
|
-
end
|
38
|
+
yield if block_given? && @corl_config_loaded && @network && @node
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -19,17 +19,17 @@ class CORL < ::Vagrant.plugin("2", :config)
|
|
19
19
|
@root_user = UNSET_VALUE
|
20
20
|
@root_home = UNSET_VALUE
|
21
21
|
|
22
|
-
@bootstrap =
|
22
|
+
@bootstrap = UNSET_VALUE
|
23
23
|
@bootstrap_path = UNSET_VALUE
|
24
24
|
@bootstrap_glob = UNSET_VALUE
|
25
25
|
@bootstrap_init = UNSET_VALUE
|
26
26
|
@auth_files = UNSET_VALUE
|
27
27
|
|
28
|
-
@seed =
|
28
|
+
@seed = UNSET_VALUE
|
29
29
|
@project_reference = UNSET_VALUE
|
30
30
|
@project_branch = UNSET_VALUE
|
31
31
|
|
32
|
-
@provision =
|
32
|
+
@provision = UNSET_VALUE
|
33
33
|
@dry_run = false
|
34
34
|
end
|
35
35
|
|
@@ -43,13 +43,17 @@ class CORL < ::Vagrant.plugin("2", :config)
|
|
43
43
|
@root_user = nil if @root_user == UNSET_VALUE
|
44
44
|
@root_home = nil if @root_home == UNSET_VALUE
|
45
45
|
|
46
|
+
@bootstrap = nil if @bootstrap == UNSET_VALUE
|
46
47
|
@bootstrap_path = nil if @bootstrap_path == UNSET_VALUE
|
47
48
|
@bootstrap_glob = nil if @bootstrap_glob == UNSET_VALUE
|
48
49
|
@bootstrap_init = nil if @bootstrap_init == UNSET_VALUE
|
49
50
|
@auth_files = nil if @auth_files == UNSET_VALUE
|
50
51
|
|
52
|
+
@seed = nil if @seed == UNSET_VALUE
|
51
53
|
@project_reference = nil if @project_reference == UNSET_VALUE
|
52
54
|
@project_branch = nil if @project_branch == UNSET_VALUE
|
55
|
+
|
56
|
+
@provision = nil if @provision == UNSET_VALUE
|
53
57
|
end
|
54
58
|
|
55
59
|
#-----------------------------------------------------------------------------
|
@@ -32,7 +32,7 @@ class CORL < ::Vagrant.plugin("2", :provisioner)
|
|
32
32
|
|
33
33
|
if network && node
|
34
34
|
# Provision the server
|
35
|
-
network.init_node(node, clean(::CORL.config(:vagrant_node_init, {
|
35
|
+
success = network.init_node(node, clean(::CORL.config(:vagrant_node_init, {
|
36
36
|
:force => config.force_updates,
|
37
37
|
:home => config.user_home,
|
38
38
|
:home_env_var => config.user_home_env_var,
|
@@ -49,6 +49,8 @@ class CORL < ::Vagrant.plugin("2", :provisioner)
|
|
49
49
|
:provision => config.provision,
|
50
50
|
:dry_run => config.dry_run
|
51
51
|
}).export))
|
52
|
+
|
53
|
+
node.ui.warn("CORL provisioner failed") unless success
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/lib/corl.rb
CHANGED
@@ -13,15 +13,16 @@
|
|
13
13
|
#-------------------------------------------------------------------------------
|
14
14
|
# Top level properties
|
15
15
|
|
16
|
-
lib_dir
|
17
|
-
core_dir
|
18
|
-
mod_dir
|
19
|
-
mixin_dir
|
20
|
-
mixin_action_dir
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
lib_dir = File.dirname(__FILE__)
|
17
|
+
core_dir = File.join(lib_dir, 'core')
|
18
|
+
mod_dir = File.join(core_dir, 'mod')
|
19
|
+
mixin_dir = File.join(core_dir, 'mixin')
|
20
|
+
mixin_action_dir = File.join(mixin_dir, 'action')
|
21
|
+
mixin_machine_dir = File.join(mixin_dir, 'machine')
|
22
|
+
macro_dir = File.join(mixin_dir, 'macro')
|
23
|
+
util_dir = File.join(core_dir, 'util')
|
24
|
+
mod_dir = File.join(core_dir, 'mod')
|
25
|
+
vagrant_dir = File.join(core_dir, 'vagrant')
|
25
26
|
|
26
27
|
#-------------------------------------------------------------------------------
|
27
28
|
# CORL requirements
|
@@ -59,6 +60,9 @@ end
|
|
59
60
|
Dir.glob(File.join(mixin_action_dir, '*.rb')).each do |file|
|
60
61
|
require file
|
61
62
|
end
|
63
|
+
Dir.glob(File.join(mixin_machine_dir, '*.rb')).each do |file|
|
64
|
+
require file
|
65
|
+
end
|
62
66
|
Dir.glob(File.join(macro_dir, '*.rb')).each do |file|
|
63
67
|
require file
|
64
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nucleon
|
@@ -263,6 +263,7 @@ files:
|
|
263
263
|
- lib/core/facade.rb
|
264
264
|
- lib/core/mixin/action/keypair.rb
|
265
265
|
- lib/core/mixin/lookup.rb
|
266
|
+
- lib/core/mixin/machine/ssh.rb
|
266
267
|
- lib/core/mixin/macro/network_settings.rb
|
267
268
|
- lib/core/mod/facter_loader.rb
|
268
269
|
- lib/core/mod/fog_aws_server.rb
|