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,15 +1,19 @@
1
1
 
2
- module Nucleon
2
+ module CORL
3
3
  module Plugin
4
- class Provisioner < CORL.plugin_class(:base)
4
+ class Provisioner < CORL.plugin_class(:nucleon, :base)
5
5
 
6
6
  include Parallel
7
7
 
8
+ extend Mixin::Builder::Global
9
+ include Mixin::Builder::Instance
10
+
8
11
  #-----------------------------------------------------------------------------
9
12
  # Provisioner plugin interface
10
13
 
11
14
  def normalize(reload)
12
15
  super
16
+ build_config.register(:dependency, :dependencies) if build_config
13
17
  yield if block_given?
14
18
  end
15
19
 
@@ -26,13 +30,6 @@ class Provisioner < CORL.plugin_class(:base)
26
30
 
27
31
  #---
28
32
 
29
- def id(name = nil)
30
- name = plugin_name if name.nil?
31
- name.to_s.gsub('::', '_').to_sym
32
- end
33
-
34
- #---
35
-
36
33
  def directory=directory
37
34
  myself[:directory] = directory
38
35
  end
@@ -44,7 +41,7 @@ class Provisioner < CORL.plugin_class(:base)
44
41
  #---
45
42
 
46
43
  def build_directory
47
- File.join(network.build_directory, plugin_provider.to_s)
44
+ File.join(network.build_directory, 'provisioners', plugin_provider.to_s)
48
45
  end
49
46
 
50
47
  #---
@@ -53,41 +50,51 @@ class Provisioner < CORL.plugin_class(:base)
53
50
  myself[:gateway] = gateway
54
51
  end
55
52
 
56
- def gateway
57
- myself[:gateway]
53
+ def gateway(index = :first, reset = false)
54
+ gateway = myself[:gateway]
55
+
56
+ unless gateway
57
+ gateways = package_gateways(reset)
58
+
59
+ unless gateways.empty?
60
+ if index == :first || index == 0
61
+ gateway = gateways[0]
62
+ elsif index == :last
63
+ gateway = gateways.pop
64
+ elsif index.integer?
65
+ gateway = gateways[index]
66
+ end
67
+ end
68
+ end
69
+ gateway
58
70
  end
59
71
 
60
- #---
61
-
62
- def packages
63
- hash(myself[:packages])
72
+ def package_gateways(node, reset = false)
73
+ gateways = []
74
+ build_info(node, reset).each do |package_name, package_info|
75
+ gateways << File.join('packages', id(package_name).to_s, package_info[:gateway]) if package_info.has_key?(:gateway)
76
+ end
77
+ gateways
64
78
  end
65
79
 
66
80
  #---
67
81
 
68
- def profiles
69
- hash(myself[:profiles])
70
- end
71
-
72
- def find_profiles(reset = false)
82
+ def find_profiles(node, reset = false)
73
83
  allowed_profiles = []
74
- build_info(reset).each do |package_name, package_info|
84
+ build_info(node, reset).each do |package_name, package_info|
75
85
  hash(package_info[:profiles]).each do |profile_name, profile_info|
76
- allowed_profiles << concatenate([ package_name, 'profile', profile_name ])
86
+ allowed_profiles << resource([ package_name, 'profile', profile_name ])
77
87
  end
78
88
  end
79
- profiles.each do |profile_name, profile_info|
80
- allowed_profiles << concatenate([ plugin_name, 'profile', profile_name ])
81
- end
82
89
  allowed_profiles
83
90
  end
84
91
  protected :find_profiles
85
92
 
86
93
  #---
87
94
 
88
- def supported_profiles(profile_names = nil)
95
+ def supported_profiles(node, profile_names = nil)
89
96
  found = []
90
- profiles = build_profiles
97
+ profiles = build_profiles(node)
91
98
 
92
99
  if profile_names.nil?
93
100
  found = profiles
@@ -101,28 +108,60 @@ class Provisioner < CORL.plugin_class(:base)
101
108
  end
102
109
  found.empty? ? false : found
103
110
  end
111
+
112
+ #---
113
+
114
+ def profile_dependencies(node, profiles)
115
+ dependencies = build_dependencies(node)[:profile]
116
+ profile_index = {}
117
+
118
+ search_profiles = lambda do |profile|
119
+ profile = profile.to_sym
120
+
121
+ if dependencies.has_key?(profile)
122
+ dependencies[profile].each do |parent_profile|
123
+ search_profiles.call(parent_profile)
124
+ end
125
+ end
126
+ profile_index[profile] = true
127
+ end
128
+
129
+ profiles.each do |profile|
130
+ search_profiles.call(profile)
131
+ end
132
+
133
+ profile_index.keys
134
+ end
135
+
136
+ #---
137
+
138
+ def build_dependencies(node, reset = false)
139
+ dependencies = cache_setting(:build_dependencies, {}, :hash)
140
+ build(node) if reset || dependencies.empty?
141
+ symbol_map(cache_setting(:build_dependencies, {}, :hash))
142
+ end
104
143
 
105
144
  #---
106
145
 
107
- def build_locations(reset = false)
146
+ def build_locations(node, reset = false)
108
147
  locations = cache_setting(:build_locations, {}, :hash)
109
- build if reset || locations.empty?
148
+ build(node) if reset || locations.empty?
110
149
  symbol_map(cache_setting(:build_locations, {}, :hash))
111
150
  end
112
151
 
113
152
  #---
114
153
 
115
- def build_info(reset = false)
154
+ def build_info(node, reset = false)
116
155
  info = cache_setting(:build_info, {}, :hash)
117
- build if reset || info.empty?
156
+ build(node) if reset || info.empty?
118
157
  symbol_map(cache_setting(:build_info, {}, :hash))
119
158
  end
120
159
 
121
160
  #---
122
161
 
123
- def build_profiles(reset = false)
162
+ def build_profiles(node, reset = false)
124
163
  profiles = cache_setting(:build_profiles, [], :array)
125
- build if reset || profiles.empty?
164
+ build(node) if reset || profiles.empty?
126
165
  cache_setting(:build_profiles, [], :array)
127
166
  end
128
167
 
@@ -135,73 +174,64 @@ class Provisioner < CORL.plugin_class(:base)
135
174
 
136
175
  #---
137
176
 
138
- def build(options = {})
139
- config = Config.ensure(options)
140
- success = true
141
- locations = Config.new({ :build => id.to_s, :package => {} })
142
- package_info = Config.new
177
+ def build(node, options = {})
178
+ config = Config.ensure(options)
179
+ environment = Util::Data.ensure_value(config[:environment], node.lookup(:corl_environment))
180
+ provider_info = network.build.config.get_hash([ :provisioners, plugin_provider ])
181
+ combined_info = Config.new
143
182
 
144
- init_package = lambda do |name, reference|
145
- package_directory = File.join(locations[:build], 'packages', id(name).to_s)
146
- package_success = true
147
-
148
- ui.info("Building package #{blue(name)} at #{purple(reference)} into #{green(package_directory)}")
183
+ provider_info.each do |package, info|
184
+ package_info = Config.new(info)
185
+ profiles = {}
149
186
 
150
- full_package_directory = File.join(build_directory, package_directory)
151
-
152
- project = CORL.configuration(extended_config(:package, {
153
- :directory => full_package_directory,
154
- :url => reference,
155
- :create => File.directory?(full_package_directory) ? false : true
156
- }))
157
- unless project
158
- ui.warn("Project #{cyan(name)} failed to initialize")
159
- package_success = false
187
+ hash(package_info[:profiles]).each do |name, profile_info|
188
+ profiles[profile_id(package, name)] = profile_info
160
189
  end
161
190
 
162
- if package_success
163
- package_info.import(project.export)
164
- locations[:package][name] = package_directory
165
-
166
- if project.get([ :provisioners, plugin_provider ], false)
167
- project.get_hash([ :provisioners, plugin_provider ]).each do |prov_name, info|
168
- if info.has_key?(:packages)
169
- info[:packages].each do |sub_name, sub_reference|
170
- unless init_package.call(sub_name, sub_reference)
171
- package_success = false
172
- break
173
- end
174
- end
175
- end
176
- end
177
- end
178
- end
179
- package_success
191
+ package_info[:profiles] = profiles
192
+ combined_info.import(package_info)
180
193
  end
181
194
 
182
- local_build_directory = File.join(build_directory, locations[:build])
195
+ FileUtils.mkdir_p(build_directory)
183
196
 
184
- FileUtils.mkdir_p(local_build_directory)
197
+ status = parallel(:build_provider, provider_info, environment, combined_info)
198
+ success = status.values.include?(false) ? false : true
185
199
 
186
- # Build packages
187
- packages.each do |name, reference|
188
- unless init_package.call(name, reference)
189
- success = false
190
- break
191
- end
200
+ if success
201
+ # Save the updates in the local project cache
202
+ set_cache_setting(:build_dependencies, network.build.dependencies.export)
203
+ set_cache_setting(:build_locations, network.build.locations.export)
204
+ set_cache_setting(:build_info, provider_info)
205
+ set_cache_setting(:build_profiles, find_profiles(node))
192
206
  end
193
-
194
- if success
195
- # Build provider specific components
196
- success = yield(locations, package_info) if block_given?
197
-
198
- if success
199
- # Save the updates in the local project cache
200
- set_cache_setting(:build_locations, locations.export)
201
- set_cache_setting(:build_info, package_info.get([ :provisioners, plugin_provider ]))
202
- set_cache_setting(:build_profiles, find_profiles)
207
+ success
208
+ end
209
+
210
+ #---
211
+
212
+ def build_provider(package, info, environment, combined_info)
213
+ profiles = hash(info[:profiles])
214
+ status = parallel(:build_profile, profiles, id(package), environment, hash(combined_info[:profiles]))
215
+ status.values.include?(false) ? false : true
216
+ end
217
+
218
+ def build_profile(name, info, package, environment, profiles)
219
+ parents = []
220
+ config = Config.new(info)
221
+ success = true
222
+
223
+ while config.has_key?(:extend) do
224
+ array(config.delete(:extend)).each do |parent|
225
+ parent = profile_id(package, parent) unless parent.match('::')
226
+
227
+ parents << parent
228
+ config.defaults(profiles[parent.to_sym])
203
229
  end
204
230
  end
231
+
232
+ build_config.set_dependency(:profile, profile_id(package, name), parents)
233
+
234
+ success = yield(process_environment(config, environment)) if block_given?
205
235
  success
206
236
  end
207
237
 
@@ -211,12 +241,15 @@ class Provisioner < CORL.plugin_class(:base)
211
241
  # Implement in providers
212
242
  nil
213
243
  end
214
-
244
+
215
245
  #---
216
246
 
217
- def provision(profiles, options = {})
218
- config = Config.ensure(options)
219
- success = yield(config) if block_given?
247
+ def provision(node, profiles, options = {})
248
+ config = Config.ensure(options)
249
+ profiles = profile_dependencies(node, profiles)
250
+ success = true
251
+
252
+ success = yield(profiles, config) if block_given?
220
253
 
221
254
  Config.save_properties(Config.get_options(:corl_log)) if success
222
255
  success
@@ -225,9 +258,9 @@ class Provisioner < CORL.plugin_class(:base)
225
258
  #-----------------------------------------------------------------------------
226
259
  # Utilities
227
260
 
228
- def self.build_info(type, data)
261
+ def self.build_info(namespace, plugin_type, data)
229
262
  data = data.split(/\s*,\s*/) if data.is_a?(String)
230
- super(type, data)
263
+ super(namespace, plugin_type, data)
231
264
  end
232
265
 
233
266
  #---
@@ -277,26 +310,13 @@ class Provisioner < CORL.plugin_class(:base)
277
310
  #---
278
311
 
279
312
  def translate_reference(reference)
280
- myself.class.translate_reference(reference)
313
+ self.class.translate_reference(reference)
281
314
  end
282
-
315
+
283
316
  #---
284
317
 
285
- def concatenate(components, capitalize = false, joiner = '::')
286
- if components.is_a?(Array)
287
- components = components.collect do |str|
288
- str.to_s.split('__')
289
- end.flatten
290
- else
291
- components = [ components.to_s.split('__') ].flatten
292
- end
293
-
294
- if capitalize
295
- name = components.collect {|str| str.capitalize }.join(joiner)
296
- else
297
- name = components.join(joiner)
298
- end
299
- name
318
+ def profile_id(package, profile)
319
+ concatenate([ package, 'profile', profile ], false)
300
320
  end
301
321
  end
302
322
  end
@@ -132,7 +132,7 @@ class Resource < Core
132
132
  config.set(:normalize_template, config.get("normalize_#{target}", true))
133
133
  config.set(:interpolate_template, config.get("interpolate_#{target}", true))
134
134
 
135
- input_data = resource[target]
135
+ input_data = resource[target]
136
136
  resource[target] = CORL.template(config, resource[name]).render(input_data)
137
137
 
138
138
  if config.get(:debug, false)
@@ -9,7 +9,13 @@ class DeleteCache < BaseAction
9
9
  @app.call env
10
10
 
11
11
  env[:ui].info I18n.t("corl.vagrant.actions.delete_cache.start")
12
- node.clear_cache
12
+
13
+ # Check for saved image
14
+ box = node.cache_setting(:box)
15
+ box_url = node.cache_setting(:box_url)
16
+
17
+ # Clear cache unless saved image
18
+ node.clear_cache unless box && box_url
13
19
  end
14
20
  end
15
21
  end
@@ -24,8 +24,8 @@ class Launcher < ::Vagrant.plugin("2", :command)
24
24
 
25
25
  def execute
26
26
  # Set the base command so we can access in any actions executed
27
- ::CORL::Vagrant.command = ::CORL.handle(self)
28
- ::CORL.executable(@argv - [ "--" ], "[ vagrant ] corl")
27
+ ::CORL::Vagrant.command = ::CORL.handle(self)
28
+ ::CORL.executable(ARGV - [ 'corl', '--' ], "[ vagrant ] corl")
29
29
  end
30
30
 
31
31
  #-----------------------------------------------------------------------------
@@ -128,8 +128,27 @@ module Config
128
128
  machine.ssh.guest_port = node.ssh_port
129
129
 
130
130
  if node.cache_setting(:use_private_key, false)
131
- #dbg(node.private_key, 'ssh private key')
132
- machine.ssh.private_key_path = node.private_key
131
+ key_dir = node.network.key_cache_directory
132
+ key_name = node.plugin_name
133
+
134
+ ssh_config = ::CORL::Config.new({
135
+ :keypair => node.keypair,
136
+ :key_dir => key_dir,
137
+ :key_name => key_name
138
+ })
139
+
140
+ if keypair = Util::SSH.unlock_private_key(node.private_key, ssh_config)
141
+ if keypair.is_a?(String)
142
+ machine.ssh.private_key_path = keypair
143
+ else
144
+ node.keypair = keypair
145
+ machine.ssh.private_key_path = keypair.private_key_file(key_dir, key_name)
146
+ end
147
+ end
148
+ unless keypair && File.exists?(machine.ssh.private_key_path)
149
+ machine.ssh.private_key_path = node.private_key
150
+ end
151
+ #dbg(machine.ssh.private_key_path, 'ssh private key')
133
152
  end
134
153
 
135
154
  Util::Data.hash(node.ssh).each do |name, data|
@@ -160,6 +179,14 @@ module Config
160
179
  box = node.cache_setting(:box)
161
180
  box_url = node.cache_setting(:box_url)
162
181
 
182
+ if box_url
183
+ box_file = box_url.gsub(/^file\:\/\//, '')
184
+ unless File.exists?(box_file)
185
+ box_url = nil
186
+ node.clear_cache
187
+ end
188
+ end
189
+
163
190
  if box && box_url
164
191
  #dbg(box, 'VM box')
165
192
  machine.vm.box = box
data/lib/corl.rb CHANGED
@@ -49,7 +49,6 @@ I18n.load_path << File.expand_path(File.join('..', 'locales', 'en.yml'), lib_dir
49
49
  # Include CORL libraries
50
50
 
51
51
  # Monkey patches (depreciate as fast as possible)
52
- nucleon_require(mod_dir, :facter_loader)
53
52
 
54
53
  #---
55
54
 
@@ -102,6 +101,7 @@ end
102
101
  nucleon_require(core_dir, :facade)
103
102
 
104
103
  # Include CORL core plugins
104
+ nucleon_require(core_dir, :build)
105
105
  nucleon_require(core_dir, :plugin)
106
106
 
107
107
  # Include Vagrant plugins (only include if running inside Vagrant)
@@ -131,13 +131,14 @@ module CORL
131
131
 
132
132
  reload(true) do |op, manager|
133
133
  if op == :define
134
- manager.define_namespace :CORL
135
-
136
- manager.define_type :configuration => :file, # Core
137
- :network => :default, # Cluster
138
- :node => :local, # Cluster
139
- :machine => :physical, # Cluster
140
- :provisioner => :puppetnode # Cluster
134
+ manager.define_types :CORL, {
135
+ :configuration => :file, # Core
136
+ :network => :corl, # Cluster
137
+ :node => :local, # Cluster
138
+ :machine => :physical, # Cluster
139
+ :builder => :package, # Cluster
140
+ :provisioner => :puppetnode # Cluster
141
+ }
141
142
  end
142
143
  end
143
144
  end
@@ -5,7 +5,7 @@ Facter.add(:corl_config_ready) do
5
5
  require 'corl'
6
6
  configured = CORL::Config.config_initialized?
7
7
 
8
- rescue Exception # Prevent abortions.
8
+ rescue # Prevent abortions.
9
9
  end
10
10
 
11
11
  configured ? true : nil
@@ -8,7 +8,7 @@ Facter.add(:vagrant_exists) do
8
8
  Facter::Util::Resolution::exec('id vagrant 2> /dev/null')
9
9
  vagrant_exists = true if $?.exitstatus == 0
10
10
 
11
- rescue Exception # Prevent abortions.
11
+ rescue # Prevent abortions.
12
12
  end
13
13
  vagrant_exists
14
14
  end
@@ -0,0 +1,51 @@
1
+
2
+ module Nucleon
3
+ module Action
4
+ module Cloud
5
+ class Create < Nucleon.plugin_class(:nucleon, :cloud_action)
6
+
7
+ include Mixin::Action::Project
8
+
9
+ #-----------------------------------------------------------------------------
10
+ # Info
11
+
12
+ def self.describe
13
+ super(:cloud, :create, 1000)
14
+ end
15
+
16
+ #-----------------------------------------------------------------------------
17
+ # Settings
18
+
19
+ def configure
20
+ super do
21
+ config.defaults(CORL.action_config(:project_create))
22
+ config[:project_reference].default = 'github:::coralnexus/network-template'
23
+ end
24
+ end
25
+
26
+ #---
27
+
28
+ def arguments
29
+ [ :project_reference ]
30
+ end
31
+
32
+ #-----------------------------------------------------------------------------
33
+ # Operations
34
+
35
+ def execute
36
+ super(false) do
37
+ info('nucleon.action.cloud.create.start')
38
+
39
+ project = project_load(settings[:path], true, true)
40
+ myself.status = code.project_failure unless project
41
+
42
+ if project.remote(:origin) =~ /coralnexus\/network\-template/
43
+ project.delete_remote(:origin)
44
+ project.delete_remote(:edit)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,61 @@
1
+
2
+ module Nucleon
3
+ module Action
4
+ module Cloud
5
+ class Hiera < CORL.plugin_class(:nucleon, :cloud_action)
6
+
7
+ #-----------------------------------------------------------------------------
8
+ # Info
9
+
10
+ def self.describe
11
+ super(:cloud, :hiera, 925)
12
+ end
13
+
14
+ #-----------------------------------------------------------------------------
15
+ # Settings
16
+
17
+ def configure
18
+ super do
19
+ register :properties, :array, []
20
+ config.defaults(CORL.action_config(:node_lookup))
21
+ end
22
+ end
23
+
24
+ #---
25
+
26
+ def ignore
27
+ [ :property ]
28
+ end
29
+
30
+ def arguments
31
+ [ :properties ]
32
+ end
33
+
34
+ #-----------------------------------------------------------------------------
35
+ # Operations
36
+
37
+ def execute
38
+ super do |node, network|
39
+ ensure_node(node) do
40
+ if settings[:properties].empty?
41
+ ui.info("\n" + CORL.render_object(node.hiera_configuration) + "\n\n", { :prefix => false })
42
+ else
43
+ settings.delete(:properties).each do |property|
44
+ value = Util::Data.to_json(node.lookup(property, nil, settings), true)
45
+
46
+ ui_group(property) do
47
+ if value.match(/\n/)
48
+ ui.info("\n\n#{value}\n\n")
49
+ else
50
+ ui.info(value)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,7 +1,15 @@
1
1
 
2
- module CORL
2
+ module Nucleon
3
3
  module Action
4
- class Images < Plugin::CloudAction
4
+ module Cloud
5
+ class Images < CORL.plugin_class(:nucleon, :cloud_action)
6
+
7
+ #-----------------------------------------------------------------------------
8
+ # Info
9
+
10
+ def self.describe
11
+ super(:cloud, :images, 850)
12
+ end
5
13
 
6
14
  #-----------------------------------------------------------------------------
7
15
  # Settings
@@ -56,3 +64,4 @@ class Images < Plugin::CloudAction
56
64
  end
57
65
  end
58
66
  end
67
+ end
@@ -0,0 +1,47 @@
1
+
2
+ module Nucleon
3
+ module Action
4
+ module Cloud
5
+ class Inspect < CORL.plugin_class(:nucleon, :cloud_action)
6
+
7
+ #-----------------------------------------------------------------------------
8
+ # Info
9
+
10
+ def self.describe
11
+ super(:cloud, :inspect, 950)
12
+ end
13
+
14
+ #-----------------------------------------------------------------------------
15
+ # Settings
16
+
17
+ def configure
18
+ super do
19
+ register :elements, :array, []
20
+ end
21
+ end
22
+
23
+ #---
24
+
25
+ def arguments
26
+ [ :elements ]
27
+ end
28
+
29
+ #-----------------------------------------------------------------------------
30
+ # Operations
31
+
32
+ def execute
33
+ super do |node, network|
34
+ ensure_network(network) do
35
+ if settings[:elements].empty?
36
+ data = network.config.export
37
+ else
38
+ data = network.config.get(settings[:elements])
39
+ end
40
+ ui.info("\n\n" + CORL.render_object(data) + "\n\n")
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end