corl 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +3 -21
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/05_ruby.sh +24 -18
- data/bootstrap/os/ubuntu/06_puppet.sh +58 -0
- data/bootstrap/os/ubuntu/10_corl.sh +1 -25
- data/corl.gemspec +5 -3
- data/lib/CORL/builder/identity.rb +14 -14
- data/lib/CORL/builder/package.rb +18 -18
- data/lib/CORL/builder/project.rb +37 -0
- data/lib/CORL/node/vagrant.rb +76 -76
- data/lib/CORL/provisioner/puppetnode.rb +98 -92
- data/lib/core/build.rb +34 -36
- data/lib/core/plugin/network.rb +2 -2
- data/lib/core/plugin/node.rb +38 -16
- data/lib/core/plugin/provisioner.rb +91 -91
- data/lib/core/util/puppet.rb +107 -107
- data/lib/core/vagrant/provisioner/config.rb +32 -19
- data/lib/core/vagrant/provisioner/provisioner.rb +17 -11
- data/lib/nucleon/action/node/bootstrap.rb +2 -0
- data/lib/nucleon/action/node/build.rb +13 -12
- data/lib/nucleon/action/node/exec.rb +21 -19
- data/lib/nucleon/action/node/provision.rb +27 -23
- data/lib/nucleon/action/node/seed.rb +2 -0
- data/locales/en.yml +27 -1
- metadata +4 -2
data/lib/core/plugin/node.rb
CHANGED
@@ -547,8 +547,10 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
547
547
|
success = false if status.values.include?(false)
|
548
548
|
|
549
549
|
if success
|
550
|
-
|
551
|
-
|
550
|
+
if array(config[:providers]).empty? || array(config[:providers]).include?("package")
|
551
|
+
status = parallel(:build_provisioners, provisioners, config)
|
552
|
+
success = false if status.values.include?(false)
|
553
|
+
end
|
552
554
|
|
553
555
|
if success
|
554
556
|
myself.build_time = Time.now.to_s if success
|
@@ -569,18 +571,20 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
569
571
|
end
|
570
572
|
|
571
573
|
def build_provider(provider, plugin, config)
|
572
|
-
|
573
|
-
|
574
|
+
if array(config[:providers]).empty? || array(config[:providers]).include?(provider.to_s)
|
575
|
+
#info("Building #{provider} components", { :i18n => false })
|
576
|
+
plugin.build(myself, config)
|
577
|
+
end
|
574
578
|
end
|
575
579
|
|
576
580
|
def build_provisioners(provider, collection, config)
|
577
|
-
info("Building #{provider} provisioner collection", { :i18n => false })
|
581
|
+
#info("Building #{provider} provisioner collection", { :i18n => false })
|
578
582
|
status = parallel(:build_provisioner, collection, provider, config)
|
579
583
|
status.values.include?(false) ? false : true
|
580
584
|
end
|
581
585
|
|
582
586
|
def build_provisioner(name, plugin, provider, config)
|
583
|
-
info("Building #{provider} #{name} provisioner components", { :i18n => false })
|
587
|
+
#info("Building #{provider} #{name} provisioner components", { :i18n => false })
|
584
588
|
plugin.build(myself, config)
|
585
589
|
end
|
586
590
|
|
@@ -827,10 +831,14 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
827
831
|
test = active_machine.exec(commands, config.export) do |type, command, data|
|
828
832
|
unless quiet
|
829
833
|
unless local?
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
+
text_output = filter_output(type, data).rstrip
|
835
|
+
|
836
|
+
unless text_output.empty?
|
837
|
+
if type == :error
|
838
|
+
warn(text_output, { :i18n => false })
|
839
|
+
else
|
840
|
+
info(text_output, { :i18n => false })
|
841
|
+
end
|
834
842
|
end
|
835
843
|
end
|
836
844
|
yield(:progress, { :type => type, :command => command, :data => data }) if block_given?
|
@@ -888,8 +896,10 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
888
896
|
|
889
897
|
admin_command = ''
|
890
898
|
if as_admin
|
891
|
-
admin_command = 'sudo' if user.to_s != 'root'
|
899
|
+
admin_command = config.delete(:admin_command, 'sudo -i') if user.to_s != 'root'
|
892
900
|
admin_command = extension_set(:admin_command, admin_command, config)
|
901
|
+
else
|
902
|
+
config.delete(:admin_command)
|
893
903
|
end
|
894
904
|
|
895
905
|
config[:commands] = [ "#{admin_command} #{command.to_s}".strip ]
|
@@ -921,8 +931,13 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
921
931
|
:data => { :encoded => encoded_config }
|
922
932
|
})
|
923
933
|
|
924
|
-
quiet
|
925
|
-
|
934
|
+
quiet = config.get(:quiet, false)
|
935
|
+
parallel = config.get(:parallel, true)
|
936
|
+
|
937
|
+
command_base = 'corl'
|
938
|
+
command_base = "NUCLEON_NO_PARALLEL=1 #{command_base}" unless parallel
|
939
|
+
|
940
|
+
result = command(command_base, { :subcommand => action_config, :as_admin => true, :quiet => quiet }) do |op, data|
|
926
941
|
yield(op, data) if block_given?
|
927
942
|
end
|
928
943
|
|
@@ -986,8 +1001,9 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
986
1001
|
user_home = config[:home]
|
987
1002
|
auth_files = config.get_array(:auth_files)
|
988
1003
|
|
989
|
-
reboot
|
990
|
-
dev_build
|
1004
|
+
reboot = config.get(:reboot, true)
|
1005
|
+
dev_build = config.get(:dev_build, false)
|
1006
|
+
ruby_version = config.get(:ruby_version, nil)
|
991
1007
|
|
992
1008
|
codes :local_path_not_found,
|
993
1009
|
:home_path_lookup_failure,
|
@@ -1018,7 +1034,7 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
1018
1034
|
auth_files = package_files.collect { |path| "'#{path}'"}
|
1019
1035
|
root_home_path = config.get(:root_home, '/root')
|
1020
1036
|
|
1021
|
-
result = command("cp #{auth_files.join(' ')} #{root_home_path}", { :as_admin => true })
|
1037
|
+
result = command("cp #{auth_files.join(' ')} #{root_home_path}", { :as_admin => true, :admin_command => 'sudo' })
|
1022
1038
|
myself.status = code.root_auth_copy_failure unless result.status == code.success
|
1023
1039
|
end
|
1024
1040
|
|
@@ -1040,6 +1056,7 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
1040
1056
|
remote_script = File.join(remote_bootstrap_path, bootstrap_init)
|
1041
1057
|
environment = "HOSTNAME='#{hostname}' "
|
1042
1058
|
environment << "DEVELOPMENT_BUILD=1 " if dev_build
|
1059
|
+
environment << "RUBY_RVM_VERSION='#{ruby_version}' " if ruby_version
|
1043
1060
|
script_names = bootstrap_scripts.empty? ? '' : bootstrap_scripts.join(' ')
|
1044
1061
|
|
1045
1062
|
myself.bootstrap_script = remote_script
|
@@ -1374,6 +1391,11 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
|
|
1374
1391
|
if data =~ /^Already evaluated [a-z]+ at [^,]+, reevaluating anyways$/
|
1375
1392
|
data = ''
|
1376
1393
|
end
|
1394
|
+
elsif type == :error
|
1395
|
+
# Hide Rubinius SAFE warning
|
1396
|
+
if data == 'WARNING: $SAFE is not supported on Rubinius.'
|
1397
|
+
data = ''
|
1398
|
+
end
|
1377
1399
|
end
|
1378
1400
|
data
|
1379
1401
|
end
|
@@ -2,73 +2,73 @@
|
|
2
2
|
module CORL
|
3
3
|
module Plugin
|
4
4
|
class Provisioner < Nucleon.plugin_class(:nucleon, :base)
|
5
|
-
|
5
|
+
|
6
6
|
include Parallel
|
7
|
-
|
7
|
+
|
8
8
|
extend Mixin::Builder::Global
|
9
9
|
include Mixin::Builder::Instance
|
10
|
-
|
10
|
+
|
11
11
|
#-----------------------------------------------------------------------------
|
12
12
|
# Provisioner plugin interface
|
13
|
-
|
13
|
+
|
14
14
|
def normalize(reload)
|
15
15
|
super
|
16
16
|
build_config.register(:dependency, :dependencies) if build_config
|
17
17
|
yield if block_given?
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
#-----------------------------------------------------------------------------
|
21
21
|
# Checks
|
22
22
|
|
23
23
|
def initialized?(options = {})
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
#-----------------------------------------------------------------------------
|
27
27
|
# Property accessors / modifiers
|
28
28
|
|
29
29
|
network_settings :provisioner
|
30
30
|
|
31
31
|
#---
|
32
|
-
|
32
|
+
|
33
33
|
def directory=directory
|
34
34
|
myself[:directory] = directory
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def directory
|
38
38
|
File.join(network.directory, myself[:directory])
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
#---
|
42
|
-
|
42
|
+
|
43
43
|
def build_directory
|
44
44
|
File.join(network.build_directory, 'provisioners', plugin_provider.to_s)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
#---
|
48
|
-
|
48
|
+
|
49
49
|
def gateway=gateway
|
50
50
|
myself[:gateway] = gateway
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def gateway(index = :first, reset = false)
|
54
54
|
gateway = myself[:gateway]
|
55
|
-
|
55
|
+
|
56
56
|
unless gateway
|
57
57
|
gateways = package_gateways(reset)
|
58
|
-
|
58
|
+
|
59
59
|
unless gateways.empty?
|
60
60
|
if index == :first || index == 0
|
61
61
|
gateway = gateways[0]
|
62
62
|
elsif index == :last
|
63
63
|
gateway = gateways.pop
|
64
64
|
elsif index.integer?
|
65
|
-
gateway = gateways[index]
|
65
|
+
gateway = gateways[index]
|
66
66
|
end
|
67
67
|
end
|
68
|
-
end
|
68
|
+
end
|
69
69
|
gateway
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def package_gateways(node, reset = false)
|
73
73
|
gateways = []
|
74
74
|
build_info(node, reset).each do |package_name, package_info|
|
@@ -76,28 +76,28 @@ class Provisioner < Nucleon.plugin_class(:nucleon, :base)
|
|
76
76
|
end
|
77
77
|
gateways
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
#---
|
81
|
-
|
81
|
+
|
82
82
|
def find_profiles(node, reset = false)
|
83
|
-
allowed_profiles = []
|
83
|
+
allowed_profiles = []
|
84
84
|
build_info(node, reset).each do |package_name, package_info|
|
85
85
|
hash(package_info[:profiles]).each do |profile_name, profile_info|
|
86
86
|
allowed_profiles << resource([ package_name, 'profile', profile_name ])
|
87
87
|
end
|
88
88
|
end
|
89
|
-
allowed_profiles
|
89
|
+
allowed_profiles
|
90
90
|
end
|
91
91
|
protected :find_profiles
|
92
|
-
|
92
|
+
|
93
93
|
#---
|
94
|
-
|
94
|
+
|
95
95
|
def supported_profiles(node, profile_names = nil)
|
96
|
-
found = []
|
96
|
+
found = []
|
97
97
|
profiles = build_profiles(node)
|
98
|
-
|
98
|
+
|
99
99
|
if profile_names.nil?
|
100
|
-
found = profiles
|
100
|
+
found = profiles
|
101
101
|
else
|
102
102
|
profile_names.each do |name|
|
103
103
|
name = name.to_s
|
@@ -108,16 +108,16 @@ class Provisioner < Nucleon.plugin_class(:nucleon, :base)
|
|
108
108
|
end
|
109
109
|
found.empty? ? false : found
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
#---
|
113
|
-
|
113
|
+
|
114
114
|
def profile_dependencies(node, profiles)
|
115
|
-
dependencies = build_dependencies(node)[:profile]
|
115
|
+
dependencies = build_dependencies(node)[:profile]
|
116
116
|
profile_index = {}
|
117
|
-
|
117
|
+
|
118
118
|
search_profiles = lambda do |profile|
|
119
119
|
profile = profile.to_sym
|
120
|
-
|
120
|
+
|
121
121
|
if dependencies.has_key?(profile)
|
122
122
|
dependencies[profile].each do |parent_profile|
|
123
123
|
search_profiles.call(parent_profile)
|
@@ -125,196 +125,196 @@ class Provisioner < Nucleon.plugin_class(:nucleon, :base)
|
|
125
125
|
end
|
126
126
|
profile_index[profile] = true
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
profiles.each do |profile|
|
130
130
|
search_profiles.call(profile)
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
profile_index.keys
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
#---
|
137
|
-
|
137
|
+
|
138
138
|
def build_dependencies(node, reset = false)
|
139
139
|
dependencies = cache_setting(:build_dependencies, {}, :hash)
|
140
140
|
build(node) if reset || dependencies.empty?
|
141
141
|
symbol_map(cache_setting(:build_dependencies, {}, :hash))
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
#---
|
145
|
-
|
145
|
+
|
146
146
|
def build_locations(node, reset = false)
|
147
147
|
locations = cache_setting(:build_locations, {}, :hash)
|
148
148
|
build(node) if reset || locations.empty?
|
149
149
|
symbol_map(cache_setting(:build_locations, {}, :hash))
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
#---
|
153
|
-
|
153
|
+
|
154
154
|
def build_info(node, reset = false)
|
155
155
|
info = cache_setting(:build_info, {}, :hash)
|
156
156
|
build(node) if reset || info.empty?
|
157
157
|
symbol_map(cache_setting(:build_info, {}, :hash))
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
#---
|
161
|
-
|
161
|
+
|
162
162
|
def build_profiles(node, reset = false)
|
163
163
|
profiles = cache_setting(:build_profiles, [], :array)
|
164
164
|
build(node) if reset || profiles.empty?
|
165
165
|
cache_setting(:build_profiles, [], :array)
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
#-----------------------------------------------------------------------------
|
169
169
|
# Provisioner operations
|
170
|
-
|
170
|
+
|
171
171
|
def register(options = {})
|
172
172
|
# Implement in providers
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
#---
|
176
|
-
|
176
|
+
|
177
177
|
def build(node, options = {})
|
178
|
-
config = Config.ensure(options)
|
178
|
+
config = Config.ensure(options)
|
179
179
|
environment = Util::Data.ensure_value(config[:environment], node.lookup(:corl_environment))
|
180
180
|
provider_info = network.build.config.get_hash([ :provisioners, plugin_provider ])
|
181
181
|
combined_info = Config.new
|
182
|
-
|
182
|
+
|
183
183
|
provider_info.each do |package, info|
|
184
184
|
package_info = Config.new(info)
|
185
185
|
profiles = {}
|
186
|
-
|
186
|
+
|
187
187
|
hash(package_info[:profiles]).each do |name, profile_info|
|
188
188
|
profiles[profile_id(package, name)] = profile_info
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
package_info[:profiles] = profiles
|
192
|
-
combined_info.import(package_info)
|
192
|
+
combined_info.import(package_info)
|
193
193
|
end
|
194
|
-
|
195
|
-
FileUtils.mkdir_p(build_directory)
|
196
|
-
|
194
|
+
|
195
|
+
FileUtils.mkdir_p(build_directory)
|
196
|
+
|
197
197
|
status = parallel(:build_provider, provider_info, environment, combined_info)
|
198
198
|
success = status.values.include?(false) ? false : true
|
199
|
-
|
200
|
-
if success
|
199
|
+
|
200
|
+
if success
|
201
201
|
# Save the updates in the local project cache
|
202
202
|
set_cache_setting(:build_dependencies, network.build.dependencies.export)
|
203
203
|
set_cache_setting(:build_locations, network.build.locations.export)
|
204
204
|
set_cache_setting(:build_info, provider_info)
|
205
205
|
set_cache_setting(:build_profiles, find_profiles(node))
|
206
206
|
end
|
207
|
-
success
|
207
|
+
success
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
#---
|
211
|
-
|
211
|
+
|
212
212
|
def build_provider(package, info, environment, combined_info)
|
213
213
|
profiles = hash(info[:profiles])
|
214
214
|
status = parallel(:build_profile, profiles, id(package), environment, hash(combined_info[:profiles]))
|
215
215
|
status.values.include?(false) ? false : true
|
216
216
|
end
|
217
|
-
|
217
|
+
|
218
218
|
def build_profile(name, info, package, environment, profiles)
|
219
219
|
parents = []
|
220
220
|
config = Config.new(info)
|
221
221
|
success = true
|
222
|
-
|
222
|
+
|
223
223
|
while config.has_key?(:extend) do
|
224
224
|
array(config.delete(:extend)).each do |parent|
|
225
225
|
parent = profile_id(package, parent) unless parent.match('::')
|
226
|
-
|
226
|
+
|
227
227
|
parents << parent
|
228
228
|
config.defaults(profiles[parent.to_sym])
|
229
229
|
end
|
230
230
|
end
|
231
|
-
|
231
|
+
|
232
232
|
build_config.set_dependency(:profile, profile_id(package, name), parents)
|
233
|
-
|
233
|
+
|
234
234
|
success = yield(process_environment(config, environment)) if block_given?
|
235
235
|
success
|
236
236
|
end
|
237
|
-
|
237
|
+
|
238
238
|
#---
|
239
|
-
|
239
|
+
|
240
240
|
def lookup(property, default = nil, options = {})
|
241
241
|
# Implement in providers
|
242
242
|
nil
|
243
243
|
end
|
244
|
-
|
244
|
+
|
245
245
|
#---
|
246
|
-
|
246
|
+
|
247
247
|
def provision(node, profiles, options = {})
|
248
|
-
config = Config.ensure(options)
|
248
|
+
config = Config.ensure(options)
|
249
249
|
profiles = profile_dependencies(node, profiles)
|
250
250
|
success = true
|
251
|
-
|
251
|
+
|
252
252
|
success = yield(profiles, config) if block_given?
|
253
|
-
|
254
|
-
Config.save_properties(Config.get_options(:corl_log))
|
253
|
+
|
254
|
+
Config.save_properties(Config.get_options(:corl_log))
|
255
255
|
success
|
256
256
|
end
|
257
|
-
|
257
|
+
|
258
258
|
#-----------------------------------------------------------------------------
|
259
259
|
# Utilities
|
260
|
-
|
261
|
-
def self.build_info(namespace, plugin_type, data)
|
260
|
+
|
261
|
+
def self.build_info(namespace, plugin_type, data)
|
262
262
|
data = data.split(/\s*,\s*/) if data.is_a?(String)
|
263
263
|
super(namespace, plugin_type, data)
|
264
264
|
end
|
265
|
-
|
265
|
+
|
266
266
|
#---
|
267
|
-
|
267
|
+
|
268
268
|
def self.translate(data)
|
269
269
|
options = super(data)
|
270
|
-
|
271
|
-
case data
|
270
|
+
|
271
|
+
case data
|
272
272
|
when String
|
273
273
|
options = { :profiles => array(data) }
|
274
274
|
when Hash
|
275
275
|
options = data
|
276
276
|
end
|
277
|
-
|
277
|
+
|
278
278
|
if options.has_key?(:profiles)
|
279
279
|
if matches = translate_reference(options[:profiles])
|
280
280
|
options[:provider] = matches[:provider]
|
281
281
|
options[:profiles] = matches[:profiles]
|
282
|
-
|
283
|
-
logger.debug("Translating provisioner options: #{options.inspect}")
|
282
|
+
|
283
|
+
logger.debug("Translating provisioner options: #{options.inspect}")
|
284
284
|
end
|
285
285
|
end
|
286
286
|
options
|
287
287
|
end
|
288
|
-
|
288
|
+
|
289
289
|
#---
|
290
|
-
|
290
|
+
|
291
291
|
def self.translate_reference(reference)
|
292
292
|
# ex: puppetnode:::profile::something,profile::somethingelse
|
293
293
|
if reference && reference.match(/^\s*([a-zA-Z0-9_-]+):::([^\s]+)\s*$/)
|
294
294
|
provider = $1
|
295
295
|
profiles = $2
|
296
|
-
|
296
|
+
|
297
297
|
logger.debug("Translating provisioner reference: #{provider} #{profiles}")
|
298
|
-
|
298
|
+
|
299
299
|
info = {
|
300
300
|
:provider => provider,
|
301
301
|
:profiles => profiles.split(/\s*,\s*/)
|
302
302
|
}
|
303
|
-
|
303
|
+
|
304
304
|
logger.debug("Project reference info: #{info.inspect}")
|
305
305
|
return info
|
306
306
|
end
|
307
307
|
nil
|
308
308
|
end
|
309
|
-
|
309
|
+
|
310
310
|
#---
|
311
|
-
|
311
|
+
|
312
312
|
def translate_reference(reference)
|
313
313
|
self.class.translate_reference(reference)
|
314
314
|
end
|
315
|
-
|
315
|
+
|
316
316
|
#---
|
317
|
-
|
317
|
+
|
318
318
|
def profile_id(package, profile)
|
319
319
|
concatenate([ package, 'profile', profile ], false)
|
320
320
|
end
|