corl 0.4.29 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/lib/core/build.rb ADDED
@@ -0,0 +1,112 @@
1
+
2
+ module CORL
3
+ class Build < Core
4
+
5
+ include Parallel
6
+
7
+ #-----------------------------------------------------------------------------
8
+ # Constructor / destructor
9
+
10
+ def initialize
11
+ @config = Config.new
12
+ @locations = Config.new
13
+
14
+ @plurals = {}
15
+ @types = {}
16
+ end
17
+
18
+ #-----------------------------------------------------------------------------
19
+ # Build lock
20
+
21
+ @@build_lock = Mutex.new
22
+
23
+ #---
24
+
25
+ def build_lock
26
+ @@build_lock
27
+ end
28
+
29
+ #-----------------------------------------------------------------------------
30
+ # Type registration
31
+
32
+ def register(type, plural = nil)
33
+ type = type.to_sym
34
+
35
+ if plural
36
+ plural = plural.to_sym
37
+ else
38
+ plural = "#{type}s".to_sym
39
+ end
40
+ @plurals[plural] = type
41
+ @types[type] = Config.new
42
+ end
43
+
44
+ #-----------------------------------------------------------------------------
45
+ # Package configuration
46
+
47
+ def config
48
+ @config
49
+ end
50
+
51
+ def import(config)
52
+ @config.import(config)
53
+ end
54
+
55
+ #-----------------------------------------------------------------------------
56
+ # Build locations
57
+
58
+ def locations
59
+ @locations
60
+ end
61
+
62
+ def set_location(provider, name, directory)
63
+ @locations.set([ provider, name ], directory)
64
+ end
65
+
66
+ def remove_location(provider, name = nil)
67
+ @locations.delete([ provider, name ])
68
+ end
69
+
70
+ #-----------------------------------------------------------------------------
71
+ # Addon build types
72
+
73
+ def method_missing(method, *args, &code)
74
+ success = false
75
+ result = nil
76
+
77
+ if method.to_s.match(/^set\_([a-z].*)$/)
78
+ name = $1.to_sym
79
+
80
+ if @types.has_key?(name) && args.length > 2
81
+ @types[name].set([ args[0], args[1] ], args[2]) if args.length > 2
82
+ success = true
83
+ end
84
+
85
+ elsif method.to_s.match(/^remove\_([a-z].*)$/)
86
+ name = $1.to_sym
87
+
88
+ if @types.has_key?(name) && args.length > 0
89
+ @types[name].delete([ args[0], args[1] ])
90
+ success = true
91
+ end
92
+
93
+ else
94
+ name = @plurals[method.to_sym]
95
+
96
+ if name && @types.has_key?(name)
97
+ result = @types[name]
98
+ success = true
99
+ end
100
+ end
101
+ super unless success # Raise NoMethodError
102
+ result
103
+ end
104
+
105
+ #-----------------------------------------------------------------------------
106
+ # Builders
107
+
108
+ def manage(plugin_type, options = {})
109
+ CORL.send(plugin_type, options)
110
+ end
111
+ end
112
+ end
data/lib/core/facade.rb CHANGED
@@ -1,6 +1,36 @@
1
1
 
2
2
  module CORL
3
3
  module Facade
4
+
5
+ #-----------------------------------------------------------------------------
6
+ # Facter lookup
7
+
8
+ @@facts = {}
9
+
10
+ def facts(reset = false)
11
+ if reset || @@facts.empty?
12
+ @@facts = {} if reset
13
+ Facter.list.each do |name|
14
+ @@facts[name] = Facter.value(name)
15
+ end
16
+ end
17
+ @@facts
18
+ end
19
+
20
+ #---
21
+
22
+ def create_fact(name, value, weight = 1000)
23
+ Facter.collection.add(name.to_sym, {
24
+ :value => value,
25
+ :weight => weight
26
+ })
27
+ end
28
+
29
+ #---
30
+
31
+ def fact(name)
32
+ Facter.value(name)
33
+ end
4
34
 
5
35
  #-----------------------------------------------------------------------------
6
36
  # Local identification
@@ -37,42 +67,52 @@ module Facade
37
67
  # Core plugin type facade
38
68
 
39
69
  def configuration(options, provider = nil)
40
- plugin(:configuration, provider, options)
70
+ plugin(:CORL, :configuration, provider, options)
41
71
  end
42
72
 
43
73
  def configurations(data, build_hash = false, keep_array = false)
44
- plugins(:configuration, data, build_hash, keep_array)
74
+ plugins(:CORL, :configuration, data, build_hash, keep_array)
45
75
  end
46
76
 
47
77
  #-----------------------------------------------------------------------------
48
78
  # Cluster plugin type facade
49
79
 
50
80
  def network(name, options = {}, provider = nil)
51
- plugin(:network, provider, Config.ensure(options).import({ :name => name }))
81
+ plugin(:CORL, :network, provider, Config.ensure(options).import({ :name => name }))
52
82
  end
53
83
 
54
84
  def networks(data, build_hash = false, keep_array = false)
55
- plugins(:network, data, build_hash, keep_array)
85
+ plugins(:CORL, :network, data, build_hash, keep_array)
56
86
  end
57
87
 
58
88
  #---
59
89
 
60
90
  def node(name, options = {}, provider = nil)
61
- plugin(:node, provider, Config.ensure(options).import({ :name => name }))
91
+ plugin(:CORL, :node, provider, Config.ensure(options).import({ :name => name }))
62
92
  end
63
93
 
64
94
  def nodes(data, build_hash = false, keep_array = false)
65
- plugins(:node, data, build_hash, keep_array)
95
+ plugins(:CORL, :node, data, build_hash, keep_array)
96
+ end
97
+
98
+ #---
99
+
100
+ def builder(options, provider = nil)
101
+ plugin(:CORL, :builder, provider, options)
102
+ end
103
+
104
+ def builder(data, build_hash = false, keep_array = false)
105
+ plugins(:CORL, :builder, data, build_hash, keep_array)
66
106
  end
67
107
 
68
108
  #---
69
109
 
70
110
  def provisioner(options, provider = nil)
71
- plugin(:provisioner, provider, options)
111
+ plugin(:CORL, :provisioner, provider, options)
72
112
  end
73
113
 
74
114
  def provisioners(data, build_hash = false, keep_array = false)
75
- plugins(:provisioner, data, build_hash, keep_array)
115
+ plugins(:CORL, :provisioner, data, build_hash, keep_array)
76
116
  end
77
117
  end
78
118
  end
@@ -0,0 +1,158 @@
1
+
2
+ module CORL
3
+ module Mixin
4
+ module Builder
5
+ module Global # Extend
6
+
7
+ #-----------------------------------------------------------------------------
8
+ # Accessors / modifiers
9
+
10
+ def resource_joiner
11
+ '::'
12
+ end
13
+
14
+ #---
15
+
16
+ def id_joiner
17
+ '__'
18
+ end
19
+
20
+ #-----------------------------------------------------------------------------
21
+ # Utilities
22
+
23
+ def id(name = nil)
24
+ name = 'unknown' if name.nil?
25
+ name = [ name ] unless name.is_a?(Array)
26
+ components = []
27
+
28
+ name.flatten.each do |component|
29
+ components << component.to_s.gsub(resource_joiner, id_joiner)
30
+ end
31
+ components.join(id_joiner).to_sym
32
+ end
33
+
34
+ #---
35
+
36
+ def resource(name = nil, capitalize = false)
37
+ name = 'unknown' if name.nil?
38
+ concatenate(name, capitalize, resource_joiner)
39
+ end
40
+
41
+ #---
42
+
43
+ def concatenate(components, capitalize = false, joiner = nil)
44
+ joiner = resource_joiner unless joiner
45
+
46
+ if components.is_a?(Array)
47
+ components = components.collect do |str|
48
+ str.to_s.split(id_joiner)
49
+ end.flatten
50
+ else
51
+ components = [ components.to_s.split(id_joiner) ].flatten
52
+ end
53
+
54
+ if capitalize
55
+ name = components.collect {|str| str.capitalize }.join(joiner)
56
+ else
57
+ name = components.join(joiner)
58
+ end
59
+ name
60
+ end
61
+
62
+ #---
63
+
64
+ def process_environment(settings, environment = nil)
65
+ config = Config.new(hash(settings))
66
+ env_config = config.delete(:environment)
67
+ environment = environment.to_sym if environment
68
+
69
+ if env_config
70
+ if environment && env_config.has_key?(environment)
71
+ local_env_config = env_config[environment]
72
+
73
+ while local_env_config && local_env_config.has_key?(:use) do
74
+ local_env_config = env_config[local_env_config[:use].to_sym]
75
+ end
76
+
77
+ config.defaults(local_env_config) if local_env_config
78
+ end
79
+ config.defaults(env_config[:default]) if env_config.has_key?(:default)
80
+ end
81
+ config.export
82
+ end
83
+ end
84
+
85
+ #-------------------------------------------------------------------------------
86
+
87
+ module Instance # Include
88
+
89
+ extend Global
90
+
91
+ #-----------------------------------------------------------------------------
92
+ # Accessors / modifiers
93
+
94
+ def resource_joiner
95
+ self.class.resource_joiner
96
+ end
97
+
98
+ #---
99
+
100
+ def id_joiner
101
+ self.class.id_joiner
102
+ end
103
+
104
+ #---
105
+
106
+ def build_directory
107
+ network.build_directory
108
+ end
109
+
110
+ #---
111
+
112
+ def build_config
113
+ return network.build if network
114
+ nil
115
+ end
116
+
117
+ #---
118
+
119
+ def build_lock
120
+ self.class.build_lock
121
+ end
122
+
123
+ #-----------------------------------------------------------------------------
124
+ # Utilities
125
+
126
+ def id(name = nil)
127
+ name = plugin_name if name.nil?
128
+ self.class.id(name)
129
+ end
130
+
131
+ #---
132
+
133
+ def resource(name = nil, capitalize = false)
134
+ name = plugin_name if name.nil?
135
+ self.class.resource(name, capitalize)
136
+ end
137
+
138
+ #---
139
+
140
+ def concatenate(components, capitalize = false, joiner = nil)
141
+ self.class.concatenate(components, capitalize, joiner)
142
+ end
143
+
144
+ #---
145
+
146
+ def internal_path(directory)
147
+ directory.gsub(network.directory + "/", '')
148
+ end
149
+
150
+ #---
151
+
152
+ def process_environment(settings, environment = nil)
153
+ self.class.process_environment(settings, environment)
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -6,20 +6,36 @@ module Lookup
6
6
  #-----------------------------------------------------------------------------
7
7
  # Facter lookup
8
8
 
9
- def facts
10
- fact_map = {}
11
-
12
- Facter.list.each do |name|
13
- fact_map[name] = Facter.value(name)
14
- end
15
-
16
- fact_map
9
+ @@facts = nil
10
+
11
+ def fact_var
12
+ @@facts
13
+ end
14
+
15
+ def fact_var=facts
16
+ @@facts = facts
17
+ end
18
+
19
+ #---
20
+
21
+ def facts(reset = false, clone = true) # Override if needed. (See node plugin)
22
+ self.fact_var = CORL.facts if reset || fact_var.nil?
23
+ return fact_var.clone if clone
24
+ fact_var
25
+ end
26
+
27
+ #---
28
+
29
+ def create_fact(name, value, reset = false)
30
+ facts(reset, false)
31
+ fact_var[name.to_sym] = value
17
32
  end
18
33
 
19
34
  #---
20
35
 
21
- def fact(name)
22
- Facter.value(name)
36
+ def fact(name, reset = false)
37
+ facts(reset, false)
38
+ fact_var[name.to_sym]
23
39
  end
24
40
 
25
41
  #-----------------------------------------------------------------------------
@@ -27,6 +43,14 @@ module Lookup
27
43
 
28
44
  @@hiera = nil
29
45
 
46
+ def hiera_var
47
+ @@hiera
48
+ end
49
+
50
+ def hiera_var=hiera
51
+ @@hiera = hiera
52
+ end
53
+
30
54
  #---
31
55
 
32
56
  def hiera_override_dir
@@ -35,13 +59,13 @@ module Lookup
35
59
 
36
60
  #---
37
61
 
38
- def hiera_facts
39
- facts # Override if needed. (See node plugin)
62
+ def hiera_lookup_prefix
63
+ '::'
40
64
  end
41
65
 
42
66
  #---
43
67
 
44
- def hiera_configuration
68
+ def hiera_configuration(local_facts = {})
45
69
  Kernel.load File.join(File.dirname(__FILE__), '..', 'mod', 'hiera_backend.rb')
46
70
 
47
71
  backends = CORL.value(:hiera_backends, [ "json", "yaml" ])
@@ -72,7 +96,7 @@ module Lookup
72
96
  end
73
97
 
74
98
  hiera_config = CORL.config(:hiera, config)
75
- loaded_facts = Util::Data.prefix('::', hiera_facts, '')
99
+ loaded_facts = Util::Data.prefix(hiera_lookup_prefix, local_facts, '')
76
100
 
77
101
  if hiera_config[:hierarchy]
78
102
  hiera_config[:hierarchy].delete('common')
@@ -96,8 +120,8 @@ module Lookup
96
120
  #---
97
121
 
98
122
  def hiera(reset = false)
99
- @@hiera = Hiera.new(:config => hiera_configuration) if reset || @@hiera.nil?
100
- @@hiera
123
+ self.hiera_var = Hiera.new(:config => hiera_configuration(facts(reset))) if reset || hiera_var.nil?
124
+ hiera_var
101
125
  end
102
126
 
103
127
  #-----------------------------------------------------------------------------
@@ -120,9 +144,11 @@ module Lookup
120
144
  #---
121
145
 
122
146
  def lookup(properties, default = nil, options = {})
123
- config = Config.ensure(options)
147
+ config = Config.new(Config.ensure(options).export)
124
148
  value = nil
125
149
 
150
+ node = config.delete(:node, nil)
151
+
126
152
  provisioner = config.get(:provisioner, nil)
127
153
 
128
154
  hiera_scope = config.get(:hiera_scope, {})
@@ -132,10 +158,12 @@ module Lookup
132
158
 
133
159
  return_property = config.get(:return_property, false)
134
160
 
161
+ return node.lookup(properties, default, config) if node
162
+
135
163
  unless properties.is_a?(Array)
136
164
  properties = [ properties ].flatten
137
165
  end
138
-
166
+
139
167
  first_property = nil
140
168
  properties.each do |property|
141
169
  property = property.to_sym
@@ -158,11 +186,14 @@ module Lookup
158
186
  unless hiera_scope.respond_to?('[]')
159
187
  hiera_scope = Hiera::Scope.new(hiera_scope)
160
188
  end
161
- value = hiera.lookup(property.to_s, nil, hiera_scope, override, context)
189
+
190
+ hiera_scope = string_map(hiera_scope) if hiera_scope.is_a?(Hash)
191
+ value = hiera.lookup(property.to_s, nil, hiera_scope, override, context)
192
+
162
193
  debug_lookup(config, property, value, "Hiera lookup")
163
194
  end
164
195
 
165
- if CORL.admin? && provisioner && value.nil?
196
+ if provisioner && value.nil?
166
197
  # Search the provisioner scope (only admins can provision a machine)
167
198
  value = CORL.provisioner({ :name => :lookup }, provisioner).lookup(property, default, config)
168
199
  debug_lookup(config, property, value, "Provisioner lookup")
@@ -6,13 +6,25 @@ module SSH
6
6
  #-----------------------------------------------------------------------------
7
7
  # SSH Operations
8
8
 
9
- def init_ssh_session(reset = false, tries = 5, sleep_secs = 5)
9
+ def init_ssh_session(reset = false, tries = 12, sleep_secs = 5)
10
10
  ssh_wait_for_ready
11
11
 
12
- success = true
13
-
12
+ success = true
13
+
14
+ public_ip = node.public_ip
15
+ user = node.user
16
+ ssh_port = node.ssh_port
17
+ private_key = node.private_key
18
+
19
+ ssh_config = Config.new({
20
+ :keypair => node.keypair,
21
+ :key_dir => node.network.key_cache_directory,
22
+ :key_name => node.plugin_name
23
+ })
24
+
14
25
  begin
15
- Util::SSH.session(node.public_ip, node.user, node.ssh_port, node.private_key, reset)
26
+ Util::SSH.session(public_ip, user, ssh_port, private_key, reset, ssh_config)
27
+ node.keypair = ssh_config[:keypair]
16
28
 
17
29
  rescue Net::SSH::HostKeyMismatch => error
18
30
  error.remember_host!
@@ -0,0 +1,49 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Builder < CORL.plugin_class(:nucleon, :base)
5
+
6
+ include Parallel
7
+
8
+ extend Mixin::Builder::Global
9
+ include Mixin::Builder::Instance
10
+
11
+ #-----------------------------------------------------------------------------
12
+ # Builder plugin interface
13
+
14
+ def normalize(reload)
15
+ super
16
+ yield if block_given?
17
+ end
18
+
19
+ #-----------------------------------------------------------------------------
20
+ # Checks
21
+
22
+ #-----------------------------------------------------------------------------
23
+ # Property accessors / modifiers
24
+
25
+ network_settings :builder
26
+
27
+ #-----------------------------------------------------------------------------
28
+ # Builder operations
29
+
30
+ def build(node, options = {})
31
+ config = Config.ensure(options)
32
+ environment = Util::Data.ensure_value(config[:environment], node.lookup(:corl_environment))
33
+ configuration = process_environment(export, environment)
34
+
35
+ FileUtils.mkdir_p(build_directory)
36
+
37
+ status = parallel(:build_provider, configuration, environment)
38
+ status.values.include?(false) ? false : true
39
+ end
40
+
41
+ #---
42
+
43
+ def build_provider(name, project_reference, environment)
44
+ # Implement in sub classes
45
+ true
46
+ end
47
+ end
48
+ end
49
+ end
@@ -23,14 +23,18 @@ module Vagrant
23
23
  @@command
24
24
  end
25
25
  end
26
+ end
27
+
28
+ #-------------------------------------------------------------------------------
26
29
 
30
+ module Nucleon
27
31
  module Plugin
28
- class CloudAction < CORL.plugin_class(:action)
32
+ class CloudAction < CORL.plugin_class(:nucleon, :action)
29
33
 
30
34
  #-----------------------------------------------------------------------------
31
35
  # Property accessor / modifiers
32
36
 
33
- def namespace
37
+ def self.namespace
34
38
  :corl
35
39
  end
36
40
 
@@ -38,8 +42,8 @@ class CloudAction < CORL.plugin_class(:action)
38
42
 
39
43
  def configure
40
44
  super do
41
- node_config
42
45
  yield if block_given?
46
+ node_config
43
47
  end
44
48
  end
45
49
 
@@ -47,13 +51,13 @@ class CloudAction < CORL.plugin_class(:action)
47
51
  # Settings
48
52
 
49
53
  def node_config
50
- node_plugins = CORL.loaded_plugins(:node)
54
+ node_plugins = CORL.loaded_plugins(:CORL, :node)
51
55
 
52
56
  register :parallel, :bool, true, 'corl.core.action.options.parallel'
53
57
  register :net_remote, :str, :edit, 'corl.core.action.options.net_remote'
54
- register :net_provider, :str, :default, 'corl.core.action.options.net_provider' do |value|
58
+ register :net_provider, :str, :corl, 'corl.core.action.options.net_provider' do |value|
55
59
  value = value.to_sym
56
- network_plugins = CORL.loaded_plugins(:network)
60
+ network_plugins = CORL.loaded_plugins(:CORL, :network)
57
61
 
58
62
  unless network_plugins.keys.include?(value)
59
63
  warn('corl.core.action.errors.network_provider', { :value => value, :choices => network_plugins.keys.join(", ") })
@@ -74,7 +78,7 @@ class CloudAction < CORL.plugin_class(:action)
74
78
  register :nodes, :array, [], 'corl.core.action.options.nodes' do |values|
75
79
  success = true
76
80
  values.each do |value|
77
- if info = CORL.plugin_class(:node).translate_reference(value)
81
+ if info = CORL.plugin_class(:CORL, :node).translate_reference(value)
78
82
  if ! node_plugins.keys.include?(info[:provider].to_sym) || info[:name].empty?
79
83
  warn('corl.core.action.errors.nodes', { :value => value, :provider => info[:provider], :name => info[:name] })
80
84
  success = false
@@ -94,20 +98,24 @@ class CloudAction < CORL.plugin_class(:action)
94
98
  #-----------------------------------------------------------------------------
95
99
  # Operations
96
100
 
97
- def validate(node, network)
101
+ def validate(node = nil, network = nil)
98
102
  super(node, network)
99
103
  end
100
104
 
101
105
  #---
102
106
 
103
- def execute
104
- super(true, true) do
105
- node_exec do |node, network|
106
- hook_config = { :node => node, :network => network }
107
+ def execute(use_network = true, &code)
108
+ if use_network
109
+ super(true, true) do
110
+ node_exec do |node, network|
111
+ hook_config = { :node => node, :network => network }
107
112
 
108
- yield(node, network) if block_given? && extension_check(:exec_init, hook_config)
109
- myself.status = extension_set(:exec_exit, status, hook_config)
113
+ code.call(node, network) if code && extension_check(:exec_init, hook_config)
114
+ myself.status = extension_set(:exec_exit, status, hook_config)
115
+ end
110
116
  end
117
+ else
118
+ super(false, false, &code)
111
119
  end
112
120
  end
113
121
 
@@ -123,9 +131,7 @@ class CloudAction < CORL.plugin_class(:action)
123
131
  # Execute action on remote nodes
124
132
  success = network.batch(settings[:nodes], settings[:node_provider], settings[:parallel]) do |node|
125
133
  exec_config = Config.new(settings)
126
- exec_config.delete(:parallel)
127
134
  exec_config.delete(:nodes)
128
- exec_config.delete(:node_provider)
129
135
 
130
136
  result = node.action(plugin_provider, exec_config) do |op, data|
131
137
  execute_remote(node, network, op, data)