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
@@ -1,10 +1,16 @@
1
1
 
2
- module Nucleon
2
+ module CORL
3
3
  module Plugin
4
- class Configuration < CORL.plugin_class(:base)
4
+ class Configuration < CORL.plugin_class(:nucleon, :base)
5
5
 
6
6
  include Mixin::SubConfig
7
7
 
8
+ #---
9
+
10
+ def self.register_ids
11
+ [ :name, :directory ]
12
+ end
13
+
8
14
  #-----------------------------------------------------------------------------
9
15
  # Configuration plugin interface
10
16
 
@@ -22,7 +28,7 @@ class Configuration < CORL.plugin_class(:base)
22
28
  :create => _delete(:create, false),
23
29
  :pull => true,
24
30
  :internal_ip => CORL.public_ip, # Needed for seeding Vagrant VMs
25
- :manage_ignore => true
31
+ :manage_ignore => _delete(:manage_ignore, true)
26
32
  }), _delete(:project_provider))
27
33
 
28
34
  _init(:autoload, true)
@@ -5,7 +5,7 @@ nucleon_require(File.dirname(__FILE__), :machine)
5
5
 
6
6
  module CORL
7
7
  module Machine
8
- class Fog < CORL.plugin_class(:machine)
8
+ class Fog < CORL.plugin_class(:CORL, :machine)
9
9
 
10
10
  include Mixin::Machine::SSH
11
11
 
@@ -184,7 +184,7 @@ class Fog < CORL.plugin_class(:machine)
184
184
  def reload(options = {}, &code)
185
185
  super do |config|
186
186
  success = code ? code.call(config) : true
187
- success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
187
+ success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success
188
188
  end
189
189
  end
190
190
 
@@ -195,7 +195,7 @@ class Fog < CORL.plugin_class(:machine)
195
195
  image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s)
196
196
 
197
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
198
+ success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success
199
199
  end
200
200
  end
201
201
 
@@ -5,7 +5,7 @@ nucleon_require(File.dirname(__FILE__), :node)
5
5
 
6
6
  module CORL
7
7
  module Node
8
- class Fog < CORL.plugin_class(:node)
8
+ class Fog < CORL.plugin_class(:CORL, :node)
9
9
 
10
10
  #-----------------------------------------------------------------------------
11
11
  # Node plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
- module Nucleon
2
+ module CORL
3
3
  module Plugin
4
- class Machine < CORL.plugin_class(:base)
4
+ class Machine < CORL.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Machine plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
- module Nucleon
2
+ module CORL
3
3
  module Plugin
4
- class Network < CORL.plugin_class(:base)
4
+ class Network < CORL.plugin_class(:nucleon, :base)
5
5
 
6
6
  init_plugin_collection(:add_node, :batch)
7
7
 
@@ -11,12 +11,15 @@ class Network < CORL.plugin_class(:base)
11
11
  def normalize(reload)
12
12
  super
13
13
 
14
- logger.info("Initializing sub configuration from source with: #{myself._export.inspect}")
14
+ logger.info("Initializing network: reloading? #{reload}")
15
15
  myself.config = CORL.configuration(Config.new(myself._export).import({ :autosave => false, :create => false })) unless reload
16
16
 
17
17
  config.delete(:directory) # TODO: Figure out what to do with this??
18
18
 
19
- ignore('build')
19
+ unless reload
20
+ @build = Build.new
21
+ ignore([ 'build', File.join('config', 'identities') ])
22
+ end
20
23
  end
21
24
 
22
25
  #---
@@ -39,15 +42,26 @@ class Network < CORL.plugin_class(:base)
39
42
  #-----------------------------------------------------------------------------
40
43
  # Property accessors / modifiers
41
44
 
42
- plugin_collection :node
43
- plugin_collection :provisioner
45
+ plugin_collection :CORL, :node
46
+ plugin_collection :CORL, :builder, :single_instance => true
47
+ plugin_collection :CORL, :provisioner
48
+
49
+ #---
50
+
51
+ def hiera_var
52
+ @hiera
53
+ end
54
+
55
+ def hiera_var=hiera
56
+ @hiera = hiera
57
+ end
44
58
 
45
59
  #---
46
60
 
47
61
  def hiera_override_dir
48
62
  File.join(directory, 'config')
49
63
  end
50
-
64
+
51
65
  #---
52
66
 
53
67
  def home
@@ -68,6 +82,11 @@ class Network < CORL.plugin_class(:base)
68
82
 
69
83
  #---
70
84
 
85
+ def key_cache_directory
86
+ File.join(build_directory, 'keys')
87
+ end
88
+ #---
89
+
71
90
  def cache
72
91
  config.cache
73
92
  end
@@ -195,6 +214,12 @@ class Network < CORL.plugin_class(:base)
195
214
  CORL.node(:test, config.export, provider)
196
215
  end
197
216
 
217
+ #---
218
+
219
+ def build
220
+ @build
221
+ end
222
+
198
223
  #-----------------------------------------------------------------------------
199
224
  # Operations
200
225
 
@@ -247,7 +272,7 @@ class Network < CORL.plugin_class(:base)
247
272
  def add_node(provider, name, options = {})
248
273
  config = Config.ensure(options)
249
274
 
250
- keypair = config.delete(:keypair, nil)
275
+ keypair = config.get(:keypair, nil)
251
276
  return false unless keypair && keypair.is_a?(Util::SSH::Keypair)
252
277
 
253
278
  remote_name = config.delete(:remote, :edit)
@@ -270,11 +295,15 @@ class Network < CORL.plugin_class(:base)
270
295
  yield(:preprocess, hook_config) if block_given?
271
296
 
272
297
  if ! node.local? && node.attach_keys(keypair) && extension_check(:add_node, hook_config)
298
+ node.keypair = keypair
299
+
273
300
  # Create new node / machine
274
301
  success = node.create do |op, data|
275
302
  block_given? ? yield("create_#{op}".to_sym, data) : data
276
303
  end
277
304
 
305
+ remote_name = nil if remote_name && ! remote(remote_name)
306
+
278
307
  if success && node.save({ :remote => remote_name, :message => "Created machine #{name} on #{provider}" })
279
308
  success = init_node(node, config.defaults({ :bootstrap => true, :seed => true })) do |op, data|
280
309
  block_given? ? yield(op, data) : data
@@ -335,7 +364,7 @@ class Network < CORL.plugin_class(:base)
335
364
 
336
365
  if success && seed_project
337
366
  # Seed machine with remote project reference
338
- result = node.seed({
367
+ result = node.node_seed({
339
368
  :project_reference => seed_project,
340
369
  :project_branch => seed_branch
341
370
  }) do |op, data|
@@ -349,7 +378,7 @@ class Network < CORL.plugin_class(:base)
349
378
 
350
379
  if success && provision
351
380
  # Run configured provisioners on machine
352
- result = node.provision(config) do |op, data|
381
+ result = node.node_provision(config) do |op, data|
353
382
  yield("provision_#{op}".to_sym, data)
354
383
  end
355
384
  success = result.status == code.success
@@ -1,7 +1,7 @@
1
1
 
2
- module Nucleon
2
+ module CORL
3
3
  module Plugin
4
- class Node < CORL.plugin_class(:base)
4
+ class Node < CORL.plugin_class(:nucleon, :base)
5
5
 
6
6
  include Parallel
7
7
  external_block_exec :exec, :command, :action
@@ -85,19 +85,53 @@ class Node < CORL.plugin_class(:base)
85
85
 
86
86
  #---
87
87
 
88
+ def fact_var
89
+ @facts
90
+ end
91
+
92
+ def fact_var=facts
93
+ @facts = facts
94
+ end
95
+
96
+ #---
97
+
98
+ def facts(reset = false, clone = true)
99
+ if reset || fact_var.nil?
100
+ default_configs = extended_config(:hiera_default_facts, {
101
+ :fqdn => hostname,
102
+ :hostname => hostname.gsub(/\..*$/, ''),
103
+ :corl_provider => plugin_provider.to_s
104
+ })
105
+ self.fact_var = Config.new(lookup_facts).defaults(default_configs).export
106
+ end
107
+ return fact_var.clone if clone
108
+ fact_var
109
+ end
110
+
111
+ #---
112
+
113
+ def hiera_var
114
+ @hiera
115
+ end
116
+
117
+ def hiera_var=hiera
118
+ @hiera = hiera
119
+ end
120
+
121
+ #---
122
+
88
123
  def hiera_override_dir
89
124
  network.hiera_override_dir
90
125
  end
91
126
 
92
127
  #---
93
128
 
94
- def hiera_facts
95
- default_configs = extended_config(:hiera_default_facts, {
96
- :fqdn => hostname,
97
- :hostname => hostname.gsub(/\..*$/, ''),
98
- :corl_provider => plugin_provider.to_s
99
- })
100
- Config.new(lookup_facts).defaults(default_configs).export
129
+ def keypair
130
+ @keypair
131
+ end
132
+
133
+ def keypair=keypair
134
+ @keypair = keypair
101
135
  end
102
136
 
103
137
  #---
@@ -144,6 +178,10 @@ class Node < CORL.plugin_class(:base)
144
178
  def hostname
145
179
  hostname = setting(:hostname)
146
180
 
181
+ unless hostname
182
+ hostname = plugin_name
183
+ end
184
+
147
185
  if hostname.to_s != ui.resource.to_s
148
186
  ui.resource = Util::Console.colorize(hostname, @class_color)
149
187
  logger = hostname
@@ -317,7 +355,7 @@ class Node < CORL.plugin_class(:base)
317
355
  provisioner_info = {}
318
356
 
319
357
  # Compose needed provisioners and profiles
320
- profiles.each do |profile|
358
+ profiles.each do |profile|
321
359
  if info = Plugin::Provisioner.translate_reference(profile)
322
360
  provider = info[:provider]
323
361
 
@@ -377,32 +415,51 @@ class Node < CORL.plugin_class(:base)
377
415
  config = Config.ensure(options)
378
416
  success = true
379
417
 
380
- provisioners.each do |provider, collection|
381
- ui.info("Building #{provider} provisioner collection")
382
-
383
- collection.each do |name, provisioner|
384
- ui.info("Building #{name} provisioner")
418
+ # TODO: Figure out what's going on with the parallel implementation here.
419
+ ENV['NUCLEON_NO_PARALLEL'] = 'true'
420
+
421
+ status = parallel(:build_provider, network.builders, config)
422
+ success = false if status.values.include?(false)
423
+
424
+ if success
425
+ status = parallel(:build_provisioners, provisioners, config)
426
+ success = false if status.values.include?(false)
427
+
428
+ if success
429
+ myself.build_time = Time.now.to_s if success
385
430
 
386
- unless provisioner.build(options)
387
- success = false
388
- break
431
+ if config.delete(:save, true)
432
+ ui.success("Saving successful build")
433
+
434
+ success = save(extended_config(:build, {
435
+ :message => config.get(:message, "Built #{plugin_provider} node: #{plugin_name}"),
436
+ :remote => config.get(:remote, :edit)
437
+ }))
389
438
  end
390
439
  end
391
440
  end
392
441
 
393
- myself.build_time = Time.now.to_s if success
442
+ ENV['NUCLEON_NO_PARALLEL'] = nil
394
443
 
395
- if success && config.delete(:save, true)
396
- ui.success("Saving successful build")
397
-
398
- success = save(extended_config(:build, {
399
- :message => config.get(:message, "Built #{plugin_provider} node: #{plugin_name}"),
400
- :remote => config.get(:remote, :edit)
401
- }))
402
- end
403
444
  success
404
445
  end
405
446
 
447
+ def build_provider(provider, plugin, config)
448
+ ui.info("Building #{provider} components")
449
+ plugin.build(myself, config)
450
+ end
451
+
452
+ def build_provisioners(provider, collection, config)
453
+ ui.info("Building #{provider} provisioner collection")
454
+ status = parallel(:build_provisioner, collection, provider, config)
455
+ status.values.include?(false) ? false : true
456
+ end
457
+
458
+ def build_provisioner(name, plugin, provider, config)
459
+ ui.info("Building #{provider} #{name} provisioner components")
460
+ plugin.build(myself, config)
461
+ end
462
+
406
463
  #---
407
464
 
408
465
  def attach_keys(keypair)
@@ -424,6 +481,9 @@ class Node < CORL.plugin_class(:base)
424
481
  if private_key && public_key
425
482
  FileUtils.chmod(0600, private_key)
426
483
  FileUtils.chmod(0644, public_key)
484
+
485
+ myself.keypair = Util::SSH.generate({ :private_key => keypair.private_key })
486
+ myself.keypair.store(network.key_cache_directory, plugin_name)
427
487
 
428
488
  save_config[:files] = [ private_key, public_key ]
429
489
 
@@ -471,7 +531,7 @@ class Node < CORL.plugin_class(:base)
471
531
  #---
472
532
 
473
533
  def create_machine(name, provider, options = {})
474
- CORL.create_plugin(:machine, provider, extended_config(name, options).import({ :meta => { :parent => myself }}))
534
+ CORL.create_plugin(:CORL, :machine, provider, extended_config(name, options).import({ :meta => { :parent => myself }}))
475
535
  end
476
536
 
477
537
  #---
@@ -651,7 +711,7 @@ class Node < CORL.plugin_class(:base)
651
711
  end
652
712
  results = test if test
653
713
 
654
- rescue Exception => error
714
+ rescue => error
655
715
  default_error.append_errors(error.message)
656
716
  end
657
717
  else
@@ -726,7 +786,7 @@ class Node < CORL.plugin_class(:base)
726
786
 
727
787
  encoded_config = Util::CLI.encode(Util::Data.clean(config.export))
728
788
  action_config = extended_config(:action, {
729
- :command => provider,
789
+ :command => provider.to_s.gsub('_', ' '),
730
790
  :data => { :encoded => encoded_config }
731
791
  })
732
792
 
@@ -792,7 +852,7 @@ class Node < CORL.plugin_class(:base)
792
852
  return Util::Data.symbol_map(Util::Data.parse_json(result.output))
793
853
  end
794
854
  end
795
- local? ? facts : custom_facts
855
+ local? ? Util::Data.merge([ CORL.facts, custom_facts ]) : custom_facts
796
856
  end
797
857
 
798
858
  #---
@@ -801,13 +861,13 @@ class Node < CORL.plugin_class(:base)
801
861
  if ! local? && bootstrap_script
802
862
  config = Config.ensure(options).import({ :property => property })
803
863
  result = run.lookup(config)
804
-
864
+
805
865
  if result.status == code.success
806
866
  return Util::Data.value(Util::Data.parse_json(result.output), default)
807
867
  end
808
868
  return default
809
869
  end
810
- options[:hiera_scope] = Util::Data.prefix('::', lookup_facts, '')
870
+ options[:hiera_scope] = Util::Data.prefix('::', facts, '')
811
871
  lookup(property, default, options)
812
872
  end
813
873
 
@@ -1138,9 +1198,9 @@ class Node < CORL.plugin_class(:base)
1138
1198
  #-----------------------------------------------------------------------------
1139
1199
  # Utilities
1140
1200
 
1141
- def self.build_info(type, data)
1201
+ def self.build_info(namespace, plugin_type, data)
1142
1202
  data = data.split(/\s*,\s*/) if data.is_a?(String)
1143
- super(type, data)
1203
+ super(namespace, plugin_type, data)
1144
1204
  end
1145
1205
 
1146
1206
  #---