corl 0.4.29 → 0.5.0

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 (230) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +16 -13
  4. data/VERSION +1 -1
  5. data/bin/corl +21 -1
  6. data/bootstrap/os/ubuntu/00_base.sh +2 -2
  7. data/bootstrap/os/ubuntu/06_puppet.sh +7 -12
  8. data/bootstrap/os/ubuntu/09_nucleon.sh +1 -1
  9. data/bootstrap/os/ubuntu/10_corl.sh +1 -4
  10. data/corl.gemspec +193 -40
  11. data/lib/CORL/builder/identity.rb +68 -0
  12. data/lib/CORL/builder/package.rb +75 -0
  13. data/lib/CORL/configuration/file.rb +5 -5
  14. data/lib/CORL/machine/{aws.rb → AWS.rb} +2 -2
  15. data/lib/CORL/machine/physical.rb +1 -1
  16. data/lib/CORL/machine/rackspace.rb +1 -1
  17. data/lib/CORL/machine/vagrant.rb +2 -2
  18. data/lib/CORL/network/{default.rb → CORL.rb} +1 -1
  19. data/lib/CORL/node/{aws.rb → AWS.rb} +1 -1
  20. data/lib/CORL/node/local.rb +1 -1
  21. data/lib/CORL/node/vagrant.rb +7 -2
  22. data/lib/CORL/provisioner/puppetnode.rb +139 -131
  23. data/lib/core/build.rb +112 -0
  24. data/lib/core/facade.rb +48 -8
  25. data/lib/core/mixin/builder.rb +158 -0
  26. data/lib/core/mixin/lookup.rb +51 -20
  27. data/lib/core/mixin/machine/ssh.rb +16 -4
  28. data/lib/core/plugin/builder.rb +49 -0
  29. data/lib/core/plugin/{action.rb → cloud_action.rb} +22 -16
  30. data/lib/core/plugin/configuration.rb +9 -3
  31. data/lib/core/plugin/fog_machine.rb +3 -3
  32. data/lib/core/plugin/fog_node.rb +1 -1
  33. data/lib/core/plugin/machine.rb +2 -2
  34. data/lib/core/plugin/network.rb +39 -10
  35. data/lib/core/plugin/node.rb +95 -35
  36. data/lib/core/plugin/provisioner.rb +133 -113
  37. data/lib/core/util/puppet/resource.rb +1 -1
  38. data/lib/core/vagrant/actions/delete_cache.rb +7 -1
  39. data/lib/core/vagrant/commands/launcher.rb +2 -2
  40. data/lib/core/vagrant/config.rb +29 -2
  41. data/lib/corl.rb +9 -8
  42. data/lib/facter/corl_config_ready.rb +1 -1
  43. data/lib/facter/vagrant_exists.rb +1 -1
  44. data/lib/nucleon/action/cloud/create.rb +51 -0
  45. data/lib/nucleon/action/cloud/hiera.rb +61 -0
  46. data/lib/{CORL/action → nucleon/action/cloud}/images.rb +11 -2
  47. data/lib/nucleon/action/cloud/inspect.rb +47 -0
  48. data/lib/{CORL/action → nucleon/action/cloud}/machines.rb +11 -2
  49. data/lib/{CORL/action → nucleon/action/cloud}/regions.rb +11 -2
  50. data/lib/{CORL/action → nucleon/action/cloud}/vagrantfile.rb +11 -2
  51. data/lib/{CORL/action/ip.rb → nucleon/action/node/IP.rb} +11 -2
  52. data/lib/{CORL/action/ssh.rb → nucleon/action/node/SSH.rb} +15 -7
  53. data/lib/{CORL/action → nucleon/action/node}/authorize.rb +11 -2
  54. data/lib/{CORL/action → nucleon/action/node}/bootstrap.rb +13 -4
  55. data/lib/nucleon/action/node/build.rb +49 -0
  56. data/lib/{CORL/action → nucleon/action/node}/destroy.rb +14 -5
  57. data/lib/{CORL/action → nucleon/action/node}/exec.rb +11 -2
  58. data/lib/{CORL/action → nucleon/action/node}/facts.rb +12 -3
  59. data/lib/{CORL/action → nucleon/action/node}/image.rb +13 -4
  60. data/lib/nucleon/action/node/keypair.rb +85 -0
  61. data/lib/{CORL/action → nucleon/action/node}/lookup.rb +13 -4
  62. data/lib/{CORL/action → nucleon/action/node}/provision.rb +30 -8
  63. data/lib/{CORL/action → nucleon/action/node}/reboot.rb +13 -4
  64. data/lib/{CORL/action → nucleon/action/node}/revoke.rb +11 -2
  65. data/lib/{CORL/action → nucleon/action/node}/seed.rb +13 -4
  66. data/lib/{CORL/action → nucleon/action/node}/spawn.rb +19 -9
  67. data/lib/{CORL/action → nucleon/action/node}/start.rb +13 -4
  68. data/lib/{CORL/action → nucleon/action/node}/stop.rb +13 -4
  69. data/lib/{CORL → nucleon}/event/puppet.rb +2 -2
  70. data/lib/{CORL → nucleon}/template/environment.rb +2 -2
  71. data/lib/puppet/indirector/corl.rb +7 -4
  72. data/lib/puppet/parser/functions/corl_resources.rb +1 -0
  73. data/lib/puppet/parser/functions/global_array.rb +2 -1
  74. data/lib/puppet/parser/functions/global_hash.rb +2 -1
  75. data/lib/puppet/parser/functions/global_param.rb +2 -1
  76. data/lib/puppet/parser/functions/module_array.rb +2 -1
  77. data/lib/puppet/parser/functions/module_hash.rb +3 -2
  78. data/lib/puppet/parser/functions/module_param.rb +3 -2
  79. data/lib/puppet/parser/functions/render.rb +1 -0
  80. data/locales/en.yml +80 -0
  81. data/rdoc/site/0.4.29/CORL/Action/Authorize.html +485 -0
  82. data/rdoc/site/0.4.29/CORL/Action/Bootstrap.html +546 -0
  83. data/rdoc/site/0.4.29/CORL/Action/Build.html +396 -0
  84. data/rdoc/site/0.4.29/CORL/Action/Destroy.html +515 -0
  85. data/rdoc/site/0.4.29/CORL/Action/Exec.html +472 -0
  86. data/rdoc/site/0.4.29/CORL/Action/Facts.html +398 -0
  87. data/rdoc/site/0.4.29/CORL/Action/Image.html +515 -0
  88. data/rdoc/site/0.4.29/CORL/Action/Images.html +514 -0
  89. data/rdoc/site/0.4.29/CORL/Action/Ip.html +395 -0
  90. data/rdoc/site/0.4.29/CORL/Action/Keypair.html +494 -0
  91. data/rdoc/site/0.4.29/CORL/Action/Lookup.html +474 -0
  92. data/rdoc/site/0.4.29/CORL/Action/Machines.html +509 -0
  93. data/rdoc/site/0.4.29/CORL/Action/Provision.html +456 -0
  94. data/rdoc/site/0.4.29/CORL/Action/Reboot.html +515 -0
  95. data/rdoc/site/0.4.29/CORL/Action/Regions.html +509 -0
  96. data/rdoc/site/0.4.29/CORL/Action/Revoke.html +483 -0
  97. data/rdoc/site/0.4.29/CORL/Action/Seed.html +544 -0
  98. data/rdoc/site/0.4.29/CORL/Action/Spawn.html +616 -0
  99. data/rdoc/site/0.4.29/CORL/Action/Ssh.html +526 -0
  100. data/rdoc/site/0.4.29/CORL/Action/Start.html +515 -0
  101. data/rdoc/site/0.4.29/CORL/Action/Stop.html +515 -0
  102. data/rdoc/site/0.4.29/CORL/Action/Vagrantfile.html +457 -0
  103. data/rdoc/site/0.4.29/CORL/Action.html +360 -0
  104. data/rdoc/site/0.4.29/CORL/Configuration/File.html +1128 -0
  105. data/rdoc/site/0.4.29/CORL/Configuration.html +339 -0
  106. data/rdoc/site/0.4.29/CORL/Errors.html +339 -0
  107. data/rdoc/site/0.4.29/CORL/Event/Puppet.html +673 -0
  108. data/rdoc/site/0.4.29/CORL/Event.html +339 -0
  109. data/rdoc/site/0.4.29/CORL/Facade.html +742 -0
  110. data/rdoc/site/0.4.29/CORL/Machine/Aws.html +733 -0
  111. data/rdoc/site/0.4.29/CORL/Machine/Fog.html +1269 -0
  112. data/rdoc/site/0.4.29/CORL/Machine/Physical.html +1039 -0
  113. data/rdoc/site/0.4.29/CORL/Machine/Rackspace.html +514 -0
  114. data/rdoc/site/0.4.29/CORL/Machine/Vagrant.html +1300 -0
  115. data/rdoc/site/0.4.29/CORL/Machine.html +343 -0
  116. data/rdoc/site/0.4.29/CORL/Mixin/Action/Keypair.html +572 -0
  117. data/rdoc/site/0.4.29/CORL/Mixin/Action.html +339 -0
  118. data/rdoc/site/0.4.29/CORL/Mixin/Lookup.html +954 -0
  119. data/rdoc/site/0.4.29/CORL/Mixin/Machine/SSH.html +643 -0
  120. data/rdoc/site/0.4.29/CORL/Mixin/Machine.html +339 -0
  121. data/rdoc/site/0.4.29/CORL/Mixin/Macro/NetworkSettings.html +464 -0
  122. data/rdoc/site/0.4.29/CORL/Mixin/Macro.html +339 -0
  123. data/rdoc/site/0.4.29/CORL/Mixin.html +342 -0
  124. data/rdoc/site/0.4.29/CORL/Network/Default.html +391 -0
  125. data/rdoc/site/0.4.29/CORL/Network.html +339 -0
  126. data/rdoc/site/0.4.29/CORL/Node/Aws.html +716 -0
  127. data/rdoc/site/0.4.29/CORL/Node/Fog.html +1192 -0
  128. data/rdoc/site/0.4.29/CORL/Node/Local.html +424 -0
  129. data/rdoc/site/0.4.29/CORL/Node/Rackspace.html +709 -0
  130. data/rdoc/site/0.4.29/CORL/Node/Vagrant.html +1451 -0
  131. data/rdoc/site/0.4.29/CORL/Node.html +343 -0
  132. data/rdoc/site/0.4.29/CORL/Plugin/CloudAction.html +810 -0
  133. data/rdoc/site/0.4.29/CORL/Plugin.html +339 -0
  134. data/rdoc/site/0.4.29/CORL/Provisioner/Puppetnode.html +1095 -0
  135. data/rdoc/site/0.4.29/CORL/Provisioner.html +339 -0
  136. data/rdoc/site/0.4.29/CORL/Template/Environment.html +528 -0
  137. data/rdoc/site/0.4.29/CORL/Template.html +339 -0
  138. data/rdoc/site/0.4.29/CORL/Util/Puppet/Resource.html +1038 -0
  139. data/rdoc/site/0.4.29/CORL/Util/Puppet/ResourceGroup.html +920 -0
  140. data/rdoc/site/0.4.29/CORL/Util/Puppet.html +1087 -0
  141. data/rdoc/site/0.4.29/CORL/Util.html +341 -0
  142. data/rdoc/site/0.4.29/CORL/Vagrant/Config.html +896 -0
  143. data/rdoc/site/0.4.29/CORL/Vagrant.html +418 -0
  144. data/rdoc/site/0.4.29/CORL.html +465 -0
  145. data/rdoc/site/0.4.29/Facter/Util/Loader.html +396 -0
  146. data/rdoc/site/0.4.29/Facter/Util.html +339 -0
  147. data/rdoc/site/0.4.29/Facter.html +339 -0
  148. data/rdoc/site/0.4.29/Fog/Compute/AWS/Server.html +423 -0
  149. data/rdoc/site/0.4.29/Fog/Compute/AWS.html +345 -0
  150. data/rdoc/site/0.4.29/Fog/Compute/RackspaceV2/Server.html +408 -0
  151. data/rdoc/site/0.4.29/Fog/Compute/RackspaceV2.html +345 -0
  152. data/rdoc/site/0.4.29/Fog/Compute.html +340 -0
  153. data/rdoc/site/0.4.29/Fog.html +340 -0
  154. data/rdoc/site/0.4.29/Hiera/Backend.html +422 -0
  155. data/rdoc/site/0.4.29/Hiera/Corl_logger.html +449 -0
  156. data/rdoc/site/0.4.29/Hiera.html +346 -0
  157. data/rdoc/site/0.4.29/Nucleon/Config.html +357 -0
  158. data/rdoc/site/0.4.29/Nucleon/Plugin/Base.html +345 -0
  159. data/rdoc/site/0.4.29/Nucleon/Plugin/Configuration.html +1213 -0
  160. data/rdoc/site/0.4.29/Nucleon/Plugin/Machine.html +1279 -0
  161. data/rdoc/site/0.4.29/Nucleon/Plugin/Network.html +1425 -0
  162. data/rdoc/site/0.4.29/Nucleon/Plugin/Node.html +3715 -0
  163. data/rdoc/site/0.4.29/Nucleon/Plugin/Provisioner.html +1297 -0
  164. data/rdoc/site/0.4.29/Nucleon/Plugin.html +344 -0
  165. data/rdoc/site/0.4.29/Nucleon.html +344 -0
  166. data/rdoc/site/0.4.29/Object.html +358 -0
  167. data/rdoc/site/0.4.29/Puppet/DataBinding/Corl.html +345 -0
  168. data/rdoc/site/0.4.29/Puppet/DataBinding.html +338 -0
  169. data/rdoc/site/0.4.29/Puppet/Indirector/Corl.html +454 -0
  170. data/rdoc/site/0.4.29/Puppet/Indirector.html +338 -0
  171. data/rdoc/site/0.4.29/Puppet/Parser/Functions.html +480 -0
  172. data/rdoc/site/0.4.29/Puppet/Parser.html +338 -0
  173. data/rdoc/site/0.4.29/Puppet.html +338 -0
  174. data/rdoc/site/0.4.29/README_rdoc.html +340 -0
  175. data/rdoc/site/0.4.29/Vagrant/Config/Loader.html +399 -0
  176. data/rdoc/site/0.4.29/Vagrant/Config.html +339 -0
  177. data/rdoc/site/0.4.29/Vagrant/Vagrantfile.html +392 -0
  178. data/rdoc/site/0.4.29/Vagrant.html +346 -0
  179. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Action/DeleteCache.html +396 -0
  180. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Action/InitKeys.html +408 -0
  181. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Action/LinkNetwork.html +406 -0
  182. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Action.html +341 -0
  183. data/rdoc/site/0.4.29/VagrantPlugins/CORL/BaseAction.html +491 -0
  184. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Command/Launcher.html +533 -0
  185. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Command.html +339 -0
  186. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Config/CORL.html +732 -0
  187. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Config.html +339 -0
  188. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Plugin.html +345 -0
  189. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Provisioner/CORL.html +536 -0
  190. data/rdoc/site/0.4.29/VagrantPlugins/CORL/Provisioner.html +339 -0
  191. data/rdoc/site/0.4.29/VagrantPlugins/CORL.html +346 -0
  192. data/rdoc/site/0.4.29/VagrantPlugins.html +346 -0
  193. data/rdoc/site/0.4.29/created.rid +96 -0
  194. data/rdoc/site/0.4.29/images/add.png +0 -0
  195. data/rdoc/site/0.4.29/images/brick.png +0 -0
  196. data/rdoc/site/0.4.29/images/brick_link.png +0 -0
  197. data/rdoc/site/0.4.29/images/bug.png +0 -0
  198. data/rdoc/site/0.4.29/images/bullet_black.png +0 -0
  199. data/rdoc/site/0.4.29/images/bullet_toggle_minus.png +0 -0
  200. data/rdoc/site/0.4.29/images/bullet_toggle_plus.png +0 -0
  201. data/rdoc/site/0.4.29/images/date.png +0 -0
  202. data/rdoc/site/0.4.29/images/delete.png +0 -0
  203. data/rdoc/site/0.4.29/images/find.png +0 -0
  204. data/rdoc/site/0.4.29/images/loadingAnimation.gif +0 -0
  205. data/rdoc/site/0.4.29/images/macFFBgHack.png +0 -0
  206. data/rdoc/site/0.4.29/images/package.png +0 -0
  207. data/rdoc/site/0.4.29/images/page_green.png +0 -0
  208. data/rdoc/site/0.4.29/images/page_white_text.png +0 -0
  209. data/rdoc/site/0.4.29/images/page_white_width.png +0 -0
  210. data/rdoc/site/0.4.29/images/plugin.png +0 -0
  211. data/rdoc/site/0.4.29/images/ruby.png +0 -0
  212. data/rdoc/site/0.4.29/images/tag_blue.png +0 -0
  213. data/rdoc/site/0.4.29/images/tag_green.png +0 -0
  214. data/rdoc/site/0.4.29/images/transparent.png +0 -0
  215. data/rdoc/site/0.4.29/images/wrench.png +0 -0
  216. data/rdoc/site/0.4.29/images/wrench_orange.png +0 -0
  217. data/rdoc/site/0.4.29/images/zoom.png +0 -0
  218. data/rdoc/site/0.4.29/index.html +339 -0
  219. data/rdoc/site/0.4.29/js/darkfish.js +155 -0
  220. data/rdoc/site/0.4.29/js/jquery.js +18 -0
  221. data/rdoc/site/0.4.29/js/navigation.js +142 -0
  222. data/rdoc/site/0.4.29/js/search.js +94 -0
  223. data/rdoc/site/0.4.29/js/search_index.js +1 -0
  224. data/rdoc/site/0.4.29/js/searcher.js +228 -0
  225. data/rdoc/site/0.4.29/rdoc.css +543 -0
  226. data/rdoc/site/0.4.29/table_of_contents.html +1561 -0
  227. metadata +192 -45
  228. data/lib/CORL/action/build.rb +0 -22
  229. data/lib/CORL/action/keypair.rb +0 -56
  230. data/lib/core/mod/facter_loader.rb +0 -15
@@ -0,0 +1,75 @@
1
+
2
+ module CORL
3
+ module Builder
4
+ class Package < CORL.plugin_class(:CORL, :builder)
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Package plugin interface
8
+
9
+ def normalize(reload)
10
+ super do
11
+ @packages = {}
12
+ end
13
+ end
14
+
15
+ #-----------------------------------------------------------------------------
16
+ # Property accessors / modifiers
17
+
18
+ def build_directory
19
+ File.join(network.build_directory, 'packages')
20
+ end
21
+
22
+ #---
23
+
24
+ def packages
25
+ @packages
26
+ end
27
+
28
+ def set_package(name, directory)
29
+ @packages[name] = directory
30
+ end
31
+
32
+ #-----------------------------------------------------------------------------
33
+ # Package interface operations
34
+
35
+ def build_provider(name, project_reference, environment)
36
+ provider_id = id(name)
37
+ directory = File.join(internal_path(build_directory), provider_id.to_s)
38
+ success = true
39
+
40
+ ui.info("Building package #{blue(name)} at #{purple(project_reference)} into #{green(directory)}")
41
+
42
+ full_directory = File.join(network.directory, directory)
43
+
44
+ unless packages.has_key?(provider_id)
45
+ project = build_config.manage(:configuration, extended_config(:package, {
46
+ :directory => full_directory,
47
+ :url => project_reference,
48
+ :create => File.directory?(full_directory) ? false : true,
49
+ :manage_ignore => false
50
+ }))
51
+ unless project
52
+ ui.warn("Package #{cyan(name)} failed to initialize")
53
+ success = false
54
+ end
55
+
56
+ if success
57
+ set_package(provider_id, full_directory)
58
+
59
+ build_config.import(project)
60
+ build_config.set_location(plugin_provider, name, directory)
61
+
62
+ if project.get([ :builders, plugin_provider ], false)
63
+ sub_packages = process_environment(project.get_hash([ :builders, plugin_provider ]), environment)
64
+
65
+ status = parallel(:build_provider, sub_packages, environment)
66
+ success = false if status.values.include?(false)
67
+ end
68
+ end
69
+ end
70
+ ui.success("Build of package #{blue(name)} finished") if success
71
+ success
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Configuration
4
- class File < CORL.plugin_class(:configuration)
4
+ class File < CORL.plugin_class(:CORL, :configuration)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Configuration plugin interface
@@ -84,7 +84,7 @@ class File < CORL.plugin_class(:configuration)
84
84
 
85
85
  def separate
86
86
  file_data = Config.new
87
- default_provider = CORL.type_default(:translator)
87
+ default_provider = CORL.type_default(:nucleon, :translator)
88
88
 
89
89
  split_config = lambda do |properties, local_router, parents = []|
90
90
  properties.each do |name, value|
@@ -234,7 +234,7 @@ class File < CORL.plugin_class(:configuration)
234
234
  begin
235
235
  FileUtils.mkdir_p(attach_path) unless Dir.exists?(attach_path)
236
236
 
237
- rescue Exception => error
237
+ rescue => error
238
238
  alert(error.message)
239
239
  success = false
240
240
  end
@@ -258,7 +258,7 @@ class File < CORL.plugin_class(:configuration)
258
258
  FileUtils.mkdir_p(attach_path) unless Dir.exists?(attach_path)
259
259
  FileUtils.cp(file, new_file)
260
260
 
261
- rescue Exception => error
261
+ rescue => error
262
262
  alert(error.message)
263
263
  success = false
264
264
  end
@@ -318,7 +318,7 @@ class File < CORL.plugin_class(:configuration)
318
318
  logger.debug("Clearing configuration file information")
319
319
  search.clear
320
320
  else
321
- translators = CORL.loaded_plugins(:translator)
321
+ translators = CORL.loaded_plugins(:nucleon, :translator)
322
322
  file_bases = [ "corl", extension_collect(:base) ].flatten
323
323
 
324
324
  project.localize do
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Machine
4
- class Aws < Fog
4
+ class AWS < Fog
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Checks
@@ -150,4 +150,4 @@ class Aws < Fog
150
150
  end
151
151
  end
152
152
  end
153
- end
153
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Machine
4
- class Physical < CORL.plugin_class(:machine)
4
+ class Physical < CORL.plugin_class(:CORL, :machine)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Machine plugin interface
@@ -60,4 +60,4 @@ class Rackspace < Fog
60
60
  end
61
61
  end
62
62
  end
63
- end
63
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Machine
4
- class Vagrant < CORL.plugin_class(:machine)
4
+ class Vagrant < CORL.plugin_class(:CORL, :machine)
5
5
 
6
6
  include Mixin::Machine::SSH
7
7
 
@@ -140,7 +140,7 @@ class Vagrant < CORL.plugin_class(:machine)
140
140
  def reload(options = {})
141
141
  super do |config|
142
142
  success = run(:reload, config)
143
- success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
143
+ success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success
144
144
  end
145
145
  end
146
146
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Network
4
- class Default < CORL.plugin_class(:network)
4
+ class CORL < CORL.plugin_class(:CORL, :network)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Cloud plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Node
4
- class Aws < Fog
4
+ class AWS < Fog
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Node plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Node
4
- class Local < CORL.plugin_class(:node)
4
+ class Local < CORL.plugin_class(:CORL, :node)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Node plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Node
4
- class Vagrant < CORL.plugin_class(:node)
4
+ class Vagrant < CORL.plugin_class(:CORL, :node)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Node plugin interface
@@ -227,10 +227,15 @@ class Vagrant < CORL.plugin_class(:node)
227
227
  if data.include?('stdin: is not a tty') || data.include?('unable to re-open stdin')
228
228
  data = ''
229
229
  end
230
+ elsif type == :output
231
+ # Hide redundant Facter output
232
+ if data =~ /^Already evaluated [a-z]+ at [^,]+, reevaluating anyways$/
233
+ data = ''
234
+ end
230
235
  end
231
236
  data
232
237
  end
233
-
238
+
234
239
  #-----------------------------------------------------------------------------
235
240
  # Machine type utilities
236
241
 
@@ -1,6 +1,7 @@
1
+
1
2
  module CORL
2
3
  module Provisioner
3
- class Puppetnode < CORL.plugin_class(:provisioner)
4
+ class Puppetnode < CORL.plugin_class(:CORL, :provisioner)
4
5
 
5
6
  @@puppet_lock = Mutex.new
6
7
 
@@ -12,6 +13,16 @@ class Puppetnode < CORL.plugin_class(:provisioner)
12
13
  @@status
13
14
  end
14
15
 
16
+ #---
17
+
18
+ def self.network
19
+ @@network
20
+ end
21
+
22
+ def self.node
23
+ @@node
24
+ end
25
+
15
26
  #-----------------------------------------------------------------------------
16
27
  # Provisioner plugin interface
17
28
 
@@ -72,124 +83,107 @@ class Puppetnode < CORL.plugin_class(:provisioner)
72
83
 
73
84
  #-----------------------------------------------------------------------------
74
85
  # Puppet initialization
86
+
87
+ def init_puppet(node, profiles)
88
+ Puppet.initialize_settings
75
89
 
76
- def init_puppet(profiles)
77
- locations = build_locations
90
+ apply_environment = nil
91
+ locations = build_locations(node)
78
92
 
79
- Puppet.initialize_settings
80
- Puppet::Util::Log.newdestination(id)
93
+ environment, environment_directory = ensure_environment(node)
94
+
95
+ Puppet::Util::Log.newdestination(id)
96
+ Puppet::Transaction::Report.indirection.cache_class = :yaml
81
97
 
82
- # TODO: Figure out how to store these damn settings in a specialized
83
- # environment without phantom empty environment issues.
98
+ Puppet[:graph] = true if CORL.log_level == :error
84
99
 
85
- Puppet[:data_binding_terminus] = 'corl'
100
+ Puppet[:node_terminus] = :plain
101
+ Puppet[:data_binding_terminus] = :corl
86
102
  Puppet[:default_file_terminus] = :file_server
87
- Puppet[:node_name_value] = id.to_s
88
103
 
89
104
  unless profiles.empty?
90
105
  modulepath = profiles.collect do |profile|
91
- File.join(build_directory, locations[:module][profile.to_sym])
92
- end
93
- Puppet[:modulepath] = array(modulepath).join(File::PATH_SEPARATOR)
106
+ profile_directory = File.join(network.directory, locations[:puppet_module][profile.to_sym])
107
+ File.directory?(profile_directory) ? profile_directory : nil
108
+ end.compact
94
109
  end
95
110
 
96
111
  if manifest = gateway
97
112
  if manifest.match(/^packages\/.*/)
98
- manifest = File.join(build_directory, locations[:build], manifest)
113
+ manifest = File.join(network.build_directory, manifest)
99
114
  else
100
115
  manifest = File.join(network.directory, directory, manifest)
101
116
  end
102
- Puppet[:manifest] = manifest
103
117
  end
104
118
 
105
- node = get_node
106
- @compiler = Puppet::Parser::Compiler.new(node)
107
- register
108
- node
119
+ Puppet[:environment] = environment
120
+ Puppet::Node::Environment.create(environment.to_sym, modulepath, manifest)
109
121
  end
110
122
  protected :init_puppet
111
-
123
+
112
124
  #---
113
125
 
114
- def get_node
115
- node_id = id.to_s
116
- node = Puppet::Node.indirection.find(node_id)
117
-
118
- if facts = Puppet::Node::Facts.indirection.find(node_id)
119
- facts.name = node_id
120
- node.merge(facts.values)
121
- end
122
- node
126
+ def get_puppet_node(environment)
127
+ Puppet[:node_name_value] = id.to_s
128
+
129
+ puppet_node = Puppet::Node.indirection.find(id.to_s, :environment => environment)
130
+
131
+ puppet_node.merge(string_map(@@node.facts))
132
+ puppet_node
123
133
  end
124
- protected :get_node
134
+ protected :get_puppet_node
125
135
 
126
136
  #-----------------------------------------------------------------------------
127
137
  # Provisioner interface operations
128
138
 
129
- def build(options = {})
130
- super do |locations, package_info|
131
- success = true
132
-
133
- # Build modules
134
- locations[:module] = {}
135
-
136
- init_profile = lambda do |package_name, profile_name, profile_info|
137
- package_id = id(package_name)
138
- base_directory = File.join(locations[:build], 'modules', package_id.to_s, profile_name.to_s)
139
- profile_success = true
139
+ def build_profile(name, info, package, environment, profiles)
140
+ super do |processed_info|
141
+ package_id = id(package)
142
+ directory = File.join(internal_path(build_directory), package_id.to_s, name.to_s)
143
+ success = true
140
144
 
141
- ui.info("Building CORL profile #{blue(profile_name)} modules into #{green(base_directory)}")
145
+ ui.info("Building CORL profile #{blue(name)} modules into #{green(directory)}")
146
+
147
+ if processed_info.has_key?(:modules)
148
+ status = parallel(:build_module, hash(processed_info[:modules]), directory, name, environment)
149
+ success = status.values.include?(false) ? false : true
142
150
 
143
- if profile_info.has_key?(:modules)
144
- profile_info[:modules].each do |module_name, module_reference|
145
- module_directory = File.join(base_directory, module_name.to_s)
146
-
147
- ui.info("Building Puppet module #{blue(module_name)} at #{purple(module_reference)} into #{green(module_directory)}")
148
-
149
- full_module_directory = File.join(build_directory, module_directory)
150
-
151
- module_project = CORL.project(extended_config(:puppet_module, {
152
- :directory => full_module_directory,
153
- :url => module_reference,
154
- :create => File.directory?(full_module_directory) ? false : true,
155
- :pull => true
156
- }))
157
- unless module_project
158
- ui.warn("Puppet module #{cyan(module_name)} failed to initialize")
159
- profile_success = false
160
- break
161
- end
162
- end
163
- locations[:module][profile_id(package_name, profile_name)] = base_directory if profile_success
164
- profile_success
165
- end
166
- end
167
-
168
- hash(package_info.get([ :provisioners, plugin_provider ])).each do |package_name, info|
169
- if info.has_key?(:profiles)
170
- info[:profiles].each do |profile_name, profile_info|
171
- unless init_profile.call(package_name, profile_name, profile_info)
172
- success = false
173
- break
174
- end
175
- end
176
- end
177
- end
178
- profiles.each do |profile_name, profile_info|
179
- unless init_profile.call(plugin_name, profile_name, profile_info)
180
- success = false
181
- break
182
- end
151
+ build_config.set_location(:puppet_module, profile_id(package, name), directory) if success
183
152
  end
153
+ ui.success("Build of profile #{blue(name)} finished") if success
184
154
  success
185
155
  end
186
156
  end
187
157
 
158
+ def build_module(name, project_reference, directory, profile, environment)
159
+ module_directory = File.join(directory, name.to_s)
160
+ full_module_directory = File.join(network.directory, module_directory)
161
+ module_project = nil
162
+ success = true
163
+
164
+ ui.info("Building #{blue(profile)} Puppet module #{blue(name)} at #{purple(project_reference)} into #{green(module_directory)}")
165
+
166
+ module_project = build_config.manage(:project, extended_config(:puppet_module, {
167
+ :directory => full_module_directory,
168
+ :url => project_reference,
169
+ :create => File.directory?(full_module_directory) ? false : true,
170
+ :pull => true,
171
+ :internal_ip => CORL.public_ip, # Needed for seeding Vagrant VMs
172
+ :manage_ignore => false
173
+ }))
174
+ unless module_project
175
+ ui.warn("Puppet module #{cyan(name)} failed to initialize")
176
+ success = false
177
+ end
178
+ ui.success("Build of #{blue(profile)} #{blue(name)} finished") if success
179
+ success
180
+ end
181
+
188
182
  #---
189
183
 
190
184
  def lookup(property, default = nil, options = {})
191
185
  Util::Puppet.lookup(property, default, Config.ensure(options).defaults({
192
- :provisioner => :puppetnode,
186
+ :provisioner => :puppetnode,
193
187
  :puppet_scope => scope
194
188
  }))
195
189
  end
@@ -198,7 +192,7 @@ class Puppetnode < CORL.plugin_class(:provisioner)
198
192
 
199
193
  def import(files, options = {})
200
194
  Util::Puppet.import(files, Config.ensure(options).defaults({
201
- :puppet_scope => scope,
195
+ :puppet_scope => scope,
202
196
  :puppet_import_base => network.directory
203
197
  }))
204
198
  end
@@ -211,18 +205,18 @@ class Puppetnode < CORL.plugin_class(:provisioner)
211
205
 
212
206
  #---
213
207
 
214
- def provision(profiles, options = {})
215
- super do |config|
216
- locations = build_locations
217
- success = true
208
+ def provision(node, profiles, options = {})
209
+ super do |processed_profiles, config|
210
+ locations = build_locations(node)
211
+ success = true
218
212
 
219
213
  include_location = lambda do |type, parameters = {}, add_search_path = false|
220
214
  classes = {}
221
215
 
222
216
  locations[:package].each do |name, package_directory|
223
- type_gateway = File.join(build_directory, package_directory, "#{type}.pp")
224
- resource_name = concatenate([ name, type ])
225
-
217
+ type_gateway = File.join(network.directory, package_directory, "#{type}.pp")
218
+ resource_name = resource([ name, type ])
219
+
226
220
  add_search_path(type, resource_name) if add_search_path
227
221
 
228
222
  if File.exists?(type_gateway)
@@ -230,16 +224,16 @@ class Puppetnode < CORL.plugin_class(:provisioner)
230
224
  classes[resource_name] = parameters
231
225
  end
232
226
 
233
- type_directory = File.join(build_directory, package_directory, type.to_s)
227
+ type_directory = File.join(network.directory, package_directory, type.to_s)
234
228
  Dir.glob(File.join(type_directory, '*.pp')).each do |file|
235
- resource_name = concatenate([ name, type, File.basename(file).gsub('.pp', '') ])
229
+ resource_name = resource([ name, type, File.basename(file).gsub('.pp', '') ])
236
230
  import(file)
237
231
  classes[resource_name] = parameters
238
232
  end
239
233
  end
240
234
 
241
235
  type_gateway = File.join(directory, "#{type}.pp")
242
- resource_name = concatenate([ plugin_name, type ])
236
+ resource_name = resource([ plugin_name, type ])
243
237
 
244
238
  add_search_path(type, resource_name) if add_search_path
245
239
 
@@ -252,57 +246,69 @@ class Puppetnode < CORL.plugin_class(:provisioner)
252
246
 
253
247
  if File.directory?(type_directory)
254
248
  Dir.glob(File.join(type_directory, '*.pp')).each do |file|
255
- resource_name = concatenate([ plugin_name, type, File.basename(file).gsub('.pp', '') ])
249
+ resource_name = resource([ plugin_name, type, File.basename(file).gsub('.pp', '') ])
256
250
  import(file)
257
251
  classes[resource_name] = parameters
258
252
  end
259
253
  end
260
254
  classes
261
255
  end
262
-
256
+
263
257
  @@puppet_lock.synchronize do
264
258
  begin
265
259
  ui.info("Starting catalog generation")
266
260
 
267
261
  @@status[id] = code.success
262
+ @@network = network
263
+ @@node = node
268
264
 
269
- start_time = Time.now
270
- node = init_puppet(profiles)
271
-
272
- # Include defaults
273
- classes = include_location.call(:default, {}, true)
265
+ start_time = Time.now
266
+ apply_environment = init_puppet(node, processed_profiles)
267
+
268
+ Puppet.override(:environments => Puppet::Environments::Static.new(apply_environment)) do
269
+ puppet_node = get_puppet_node(apply_environment.name)
270
+ @compiler = Puppet::Parser::Compiler.new(puppet_node)
271
+
272
+ # Register Puppet module plugins
273
+ register
274
+
275
+ # Include defaults
276
+ classes = include_location.call(:default, {}, true)
274
277
 
275
- # Import needed profiles
276
- include_location.call(:profiles, {}, false)
278
+ # Import needed profiles
279
+ include_location.call(:profiles, {}, false)
277
280
 
278
- profiles.each do |profile|
279
- classes[profile.to_s] = { :require => 'Anchor[profile_start]' }
280
- end
281
-
282
- # Compile catalog
283
- node.classes = classes
284
- compiler.compile
285
-
286
- # Start system configuration
287
- catalog = compiler.catalog.to_ral
288
- catalog.finalize
289
- catalog.retrieval_duration = Time.now - start_time
290
-
291
- unless config.get(:dry_run, false)
292
- ui.info("\n", { :prefix => false })
293
- ui.info("Starting configuration run")
294
-
295
- configurer = Puppet::Configurer.new
296
- if ! configurer.run(:catalog => catalog, :pluginsync => false)
297
- success = false
281
+ processed_profiles.each do |profile|
282
+ classes[profile.to_s] = { :require => 'Anchor[profile_start]' }
283
+ end
284
+
285
+ puppet_node.classes = classes
286
+
287
+ # Compile catalog
288
+ compiler.compile
289
+
290
+ catalog = compiler.catalog.to_ral
291
+ catalog.finalize
292
+ catalog.retrieval_duration = Time.now - start_time
293
+
294
+ unless config.get(:dry_run, false)
295
+ ui.info("\n", { :prefix => false })
296
+ ui.info("Starting configuration run")
297
+
298
+ # Configure the machine
299
+ configurer = Puppet::Configurer.new
300
+ if ! configurer.run(:catalog => catalog, :pluginsync => false)
301
+ success = false
302
+ end
298
303
  end
299
304
  end
300
305
 
301
306
  rescue Exception => error
302
- raise error
303
307
  Puppet.log_exception(error)
308
+ raise error
304
309
  end
305
310
  end
311
+
306
312
  success = false if @@status[id] != code.success
307
313
  success
308
314
  end
@@ -311,15 +317,17 @@ class Puppetnode < CORL.plugin_class(:provisioner)
311
317
  #-----------------------------------------------------------------------------
312
318
  # Utilities
313
319
 
314
- def profile_id(package_name, profile_name)
315
- concatenate([ package_name, 'profile', profile_name ], false)
316
- end
317
-
318
- #---
319
-
320
- def concatenate(components, capitalize = false)
321
- super(components, capitalize, '::')
320
+ def ensure_environment(node)
321
+ base_directory = Puppet[:environmentpath]
322
+ environment = node.lookup(:corl_environment)
323
+ env_directory = File.join(base_directory, environment)
324
+
325
+ FileUtils.mkdir_p(env_directory)
326
+ FileUtils.mkdir_p(File.join(env_directory, 'manifests'))
327
+ FileUtils.mkdir_p(File.join(env_directory, 'modules'))
328
+ [ environment, env_directory ]
322
329
  end
330
+ protected :ensure_environment
323
331
  end
324
332
  end
325
333
  end