corl 0.4.2 → 0.4.3

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.
Files changed (41) hide show
  1. data/Gemfile.lock +1 -1
  2. data/VERSION +1 -1
  3. data/corl.gemspec +12 -7
  4. data/lib/CORL/action/build.rb +30 -0
  5. data/lib/CORL/action/provision.rb +34 -8
  6. data/lib/CORL/configuration/file.rb +50 -64
  7. data/lib/CORL/provisioner/puppetnode.rb +186 -314
  8. data/lib/core/mixin/lookup.rb +20 -15
  9. data/lib/core/mixin/macro/network_settings.rb +52 -0
  10. data/lib/core/plugin/action.rb +1 -1
  11. data/lib/core/plugin/configuration.rb +43 -4
  12. data/lib/core/plugin/network.rb +16 -3
  13. data/lib/core/plugin/node.rb +69 -2
  14. data/lib/core/plugin/provisioner.rb +286 -11
  15. data/lib/{CORL/provisioner/puppetnode → core/util/puppet}/resource.rb +36 -40
  16. data/lib/{CORL/provisioner/puppetnode → core/util/puppet}/resource_group.rb +33 -41
  17. data/lib/core/util/puppet.rb +303 -0
  18. data/lib/corl.rb +34 -11
  19. data/lib/facter/corl_build.rb +8 -0
  20. data/lib/facter/corl_exists.rb +3 -3
  21. data/lib/facter/corl_network.rb +1 -1
  22. data/lib/facter/custom_facts.rb +24 -0
  23. data/lib/facter/vagrant_exists.rb +15 -0
  24. data/lib/hiera/corl_logger.rb +1 -1
  25. data/lib/puppet/indirector/corl.rb +2 -2
  26. data/lib/puppet/parser/functions/corl_include.rb +10 -14
  27. data/lib/puppet/parser/functions/corl_initialize.rb +15 -0
  28. data/lib/puppet/parser/functions/{deep_merge.rb → corl_merge.rb} +4 -4
  29. data/lib/puppet/parser/functions/corl_resources.rb +9 -4
  30. data/lib/puppet/parser/functions/global_array.rb +1 -1
  31. data/lib/puppet/parser/functions/global_hash.rb +1 -1
  32. data/lib/puppet/parser/functions/global_param.rb +1 -1
  33. data/lib/puppet/parser/functions/interpolate.rb +1 -1
  34. data/lib/puppet/parser/functions/module_array.rb +8 -9
  35. data/lib/puppet/parser/functions/module_hash.rb +7 -8
  36. data/lib/puppet/parser/functions/module_param.rb +4 -5
  37. data/lib/puppet/parser/functions/name.rb +1 -1
  38. data/lib/puppet/parser/functions/render.rb +5 -5
  39. metadata +34 -29
  40. data/lib/CORL/extension/puppetloader.rb +0 -24
  41. data/lib/puppet/parser/functions/config_initialized.rb +0 -26
data/Gemfile.lock CHANGED
@@ -68,7 +68,7 @@ GEM
68
68
  netrc (0.7.7)
69
69
  nokogiri (1.6.1)
70
70
  mini_portile (~> 0.5.0)
71
- nucleon (0.1.4)
71
+ nucleon (0.1.6)
72
72
  celluloid (~> 0.15)
73
73
  childprocess (~> 0.5.0)
74
74
  deep_merge (~> 1.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
data/corl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "corl"
8
- s.version = "0.4.2"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adrian Webb"]
12
- s.date = "2014-03-05"
12
+ s.date = "2014-03-16"
13
13
  s.description = "Framework that provides a simple foundation for growing organically in the cloud"
14
14
  s.email = "adrian.webb@coralnexus.com"
15
15
  s.executables = ["corl"]
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
45
45
  "corl.gemspec",
46
46
  "lib/CORL/action/authorize.rb",
47
47
  "lib/CORL/action/bootstrap.rb",
48
+ "lib/CORL/action/build.rb",
48
49
  "lib/CORL/action/destroy.rb",
49
50
  "lib/CORL/action/exec.rb",
50
51
  "lib/CORL/action/image.rb",
@@ -60,7 +61,6 @@ Gem::Specification.new do |s|
60
61
  "lib/CORL/action/stop.rb",
61
62
  "lib/CORL/configuration/file.rb",
62
63
  "lib/CORL/event/puppet.rb",
63
- "lib/CORL/extension/puppetloader.rb",
64
64
  "lib/CORL/machine/aws.rb",
65
65
  "lib/CORL/machine/physical.rb",
66
66
  "lib/CORL/machine/rackspace.rb",
@@ -69,13 +69,12 @@ Gem::Specification.new do |s|
69
69
  "lib/CORL/node/local.rb",
70
70
  "lib/CORL/node/rackspace.rb",
71
71
  "lib/CORL/provisioner/puppetnode.rb",
72
- "lib/CORL/provisioner/puppetnode/resource.rb",
73
- "lib/CORL/provisioner/puppetnode/resource_group.rb",
74
72
  "lib/CORL/template/environment.rb",
75
73
  "lib/core/errors.rb",
76
74
  "lib/core/facade.rb",
77
75
  "lib/core/mixin/action/keypair.rb",
78
76
  "lib/core/mixin/lookup.rb",
77
+ "lib/core/mixin/macro/network_settings.rb",
79
78
  "lib/core/mod/fog_aws_server.rb",
80
79
  "lib/core/mod/hiera_backend.rb",
81
80
  "lib/core/plugin/action.rb",
@@ -86,17 +85,23 @@ Gem::Specification.new do |s|
86
85
  "lib/core/plugin/network.rb",
87
86
  "lib/core/plugin/node.rb",
88
87
  "lib/core/plugin/provisioner.rb",
88
+ "lib/core/util/puppet.rb",
89
+ "lib/core/util/puppet/resource.rb",
90
+ "lib/core/util/puppet/resource_group.rb",
89
91
  "lib/corl.rb",
92
+ "lib/facter/corl_build.rb",
90
93
  "lib/facter/corl_config_ready.rb",
91
94
  "lib/facter/corl_exists.rb",
92
95
  "lib/facter/corl_network.rb",
96
+ "lib/facter/custom_facts.rb",
97
+ "lib/facter/vagrant_exists.rb",
93
98
  "lib/hiera/corl_logger.rb",
94
99
  "lib/puppet/indirector/corl.rb",
95
100
  "lib/puppet/indirector/data_binding/corl.rb",
96
- "lib/puppet/parser/functions/config_initialized.rb",
97
101
  "lib/puppet/parser/functions/corl_include.rb",
102
+ "lib/puppet/parser/functions/corl_initialize.rb",
103
+ "lib/puppet/parser/functions/corl_merge.rb",
98
104
  "lib/puppet/parser/functions/corl_resources.rb",
99
- "lib/puppet/parser/functions/deep_merge.rb",
100
105
  "lib/puppet/parser/functions/ensure.rb",
101
106
  "lib/puppet/parser/functions/file_exists.rb",
102
107
  "lib/puppet/parser/functions/global_array.rb",
@@ -0,0 +1,30 @@
1
+
2
+ module CORL
3
+ module Action
4
+ class Build < Plugin::CloudAction
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Settings
8
+
9
+ def configure
10
+ super do
11
+ codes :network_failure
12
+ end
13
+ end
14
+
15
+ #-----------------------------------------------------------------------------
16
+ # Operations
17
+
18
+ def execute
19
+ super do |node, network|
20
+ if network && node
21
+ info('corl.actions.build.start')
22
+ node.build
23
+ else
24
+ myself.status = code.network_failure
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -8,22 +8,48 @@ class Provision < Plugin::CloudAction
8
8
 
9
9
  def configure
10
10
  super do
11
- register :provider, :str, :puppetnode
12
- register :directory, :str, :default
11
+ codes :network_failure,
12
+ :provision_failure
13
13
  end
14
14
  end
15
15
 
16
- def arguments
17
- [ :directory ]
18
- end
19
-
20
16
  #-----------------------------------------------------------------------------
21
17
  # Operations
22
18
 
23
19
  def execute
24
20
  super do |node, network|
25
- info('corl.actions.provision.start')
26
-
21
+ if network && node
22
+ info('corl.actions.provision.start')
23
+
24
+ success = true
25
+
26
+ if CORL.admin?
27
+ unless node.build_time && File.directory?(network.build_directory)
28
+ success = node.build
29
+ end
30
+
31
+ if success
32
+ provisioner_info = node.provisioner_info
33
+
34
+ node.provisioners.each do |provider, collection|
35
+ provider_info = provisioner_info[provider]
36
+ profiles = provider_info[:profiles]
37
+
38
+ collection.each do |name, provisioner|
39
+ build_profiles = provisioner.build_profiles
40
+
41
+ if supported_profiles = provisioner.supported_profiles(profiles)
42
+ profile_success = provisioner.provision(supported_profiles)
43
+ success = false unless profile_success
44
+ end
45
+ end
46
+ end
47
+ myself.status = code.provision_failure unless success
48
+ end
49
+ end
50
+ else
51
+ myself.status = code.network_failure
52
+ end
27
53
  end
28
54
  end
29
55
  end
@@ -7,19 +7,10 @@ class File < CORL.plugin_class(:configuration)
7
7
  # Configuration plugin interface
8
8
 
9
9
  def normalize(reload)
10
- super
11
-
12
- logger.info("Setting source configuration project")
13
- @project = CORL.project(extended_config(:project, {
14
- :directory => _delete(:directory, Dir.pwd),
15
- :url => _delete(:url),
16
- :revision => _delete(:revision)
17
- }), _delete(:project_provider))
18
-
19
- _set(:search, Config.new)
20
- _set(:router, Config.new)
21
-
22
- set_location(@project)
10
+ super do
11
+ _set(:search, Config.new)
12
+ _set(:router, Config.new)
13
+ end
23
14
  end
24
15
 
25
16
  #---
@@ -30,22 +21,9 @@ class File < CORL.plugin_class(:configuration)
30
21
  Util::Disk.close(file_name)
31
22
  end
32
23
  end
33
-
34
- #-----------------------------------------------------------------------------
35
- # Checks
36
-
37
- def can_persist?
38
- project.can_persist?
39
- end
40
-
24
+
41
25
  #-----------------------------------------------------------------------------
42
26
  # Property accessors / modifiers
43
-
44
- def project
45
- @project
46
- end
47
-
48
- #---
49
27
 
50
28
  def search
51
29
  _get(:search)
@@ -60,29 +38,10 @@ class File < CORL.plugin_class(:configuration)
60
38
  #-----------------------------------------------------------------------------
61
39
 
62
40
  def set_location(directory)
63
- if directory && directory.is_a?(CORL::Plugin::Project)
64
- logger.debug("Setting source project directory from other project at #{directory.directory}")
65
- project.set_location(directory.directory)
66
-
67
- elsif directory && directory.is_a?(String) || directory.is_a?(Symbol)
68
- logger.debug("Setting source project directory to #{directory}")
69
- project.set_location(directory.to_s)
70
- end
41
+ super
71
42
  search_files if directory
72
43
  end
73
44
 
74
- #---
75
-
76
- def remote(name)
77
- project.remote(name)
78
- end
79
-
80
- #---
81
-
82
- def set_remote(name, location)
83
- project.set_remote(name, location)
84
- end
85
-
86
45
  #-----------------------------------------------------------------------------
87
46
  # Configuration loading / saving
88
47
 
@@ -132,10 +91,13 @@ class File < CORL.plugin_class(:configuration)
132
91
  # file_data[config_name][key...] = config
133
92
 
134
93
  def separate
135
- file_data = Config.new
94
+ file_data = Config.new
95
+ default_provider = CORL.type_default(:translator)
136
96
 
137
97
  split_config = lambda do |properties, local_router, parents = []|
138
98
  properties.each do |name, value|
99
+ next if name.to_sym == :nodes
100
+
139
101
  keys = [ parents, name ].flatten
140
102
 
141
103
  if value.is_a?(Hash) && ! value.empty?
@@ -171,8 +133,7 @@ class File < CORL.plugin_class(:configuration)
171
133
  file_data.set([ config_name, keys ].flatten, value)
172
134
  else
173
135
  # Resort to sane defaults
174
- default_provider = CORL.type_default(:translator)
175
- config_name = "corl.#{default_provider}"
136
+ config_name = "corl.#{default_provider}"
176
137
  file_data.set([ config_name, keys ].flatten, value)
177
138
  end
178
139
  end
@@ -180,8 +141,16 @@ class File < CORL.plugin_class(:configuration)
180
141
  end
181
142
  end
182
143
 
144
+ if config.get(:nodes, false)
145
+ config[:nodes].each do |provider, data|
146
+ data.each do |name, info|
147
+ file_data.set([ ::File.join('nodes', provider.to_s, "#{name}.#{default_provider}"), :nodes, provider, name ], info)
148
+ end
149
+ end
150
+ end
151
+
183
152
  # Whew! Glad that's over...
184
- split_config.call(config.export, router.export)
153
+ split_config.call(Util::Data.subset(config.export, config.keys - [ :nodes ]), router.export)
185
154
  file_data
186
155
  end
187
156
  protected :separate
@@ -313,27 +282,44 @@ class File < CORL.plugin_class(:configuration)
313
282
  # Utilities
314
283
 
315
284
  def search_files
285
+
286
+ add_search_file = lambda do |config_name, file, provider, info|
287
+ if Util::Disk.exists?(file)
288
+ search[config_name] = {
289
+ :provider => provider,
290
+ :info => info,
291
+ :file => file
292
+ }
293
+ ObjectSpace.define_finalizer(myself, myself.class.finalize(file))
294
+ else
295
+ logger.info("Configuration file #{file} does not exist")
296
+ end
297
+ end
298
+
316
299
  if Util::Data.empty?(project.directory)
317
300
  logger.debug("Clearing configuration file information")
318
301
  search.clear
319
302
  else
320
- file_bases = [ "corl", extension_collect(:base) ].flatten
303
+ translators = CORL.loaded_plugins(:translator)
304
+ file_bases = [ "corl", extension_collect(:base) ].flatten
305
+
306
+ project.localize do
307
+ translators.each do |provider, info|
308
+ Dir.glob(::File.join('nodes', '**', "*.#{provider}")).each do |file|
309
+ config_name = file
310
+ file = ::File.join(project.directory, file)
311
+
312
+ add_search_file.call(config_name, file, provider, info)
313
+ end
314
+ end
315
+ end
321
316
 
322
- Manager.connection.loaded_plugins(:translator).each do |provider, info|
317
+ translators.each do |provider, info|
323
318
  file_bases.each do |file_base|
324
319
  config_name = "#{file_base}.#{provider}"
325
320
  file = Util::Disk.filename([ project.directory, config_name ])
326
-
327
- if Util::Disk.exists?(file)
328
- search[config_name] = {
329
- :provider => provider,
330
- :info => info,
331
- :file => file
332
- }
333
- ObjectSpace.define_finalizer(myself, myself.class.finalize(file))
334
- else
335
- logger.info("Configuration file #{file} does not exist")
336
- end
321
+
322
+ add_search_file.call(config_name, file, provider, info)
337
323
  end
338
324
  end
339
325
  logger.debug("Setting configuration file information to #{search.inspect}")