corl 0.5.0 → 0.5.1

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 (202) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/VERSION +1 -1
  4. data/bootstrap/os/ubuntu/06_puppet.sh +1 -1
  5. data/corl.gemspec +171 -3
  6. data/lib/CORL/builder/identity.rb +6 -3
  7. data/lib/CORL/builder/package.rb +3 -3
  8. data/lib/CORL/configuration/file.rb +21 -7
  9. data/lib/CORL/machine/vagrant.rb +3 -3
  10. data/lib/CORL/node/vagrant.rb +2 -5
  11. data/lib/CORL/provisioner/puppetnode.rb +8 -8
  12. data/lib/core/facade.rb +7 -3
  13. data/lib/core/mixin/action/keypair.rb +3 -3
  14. data/lib/core/mixin/action/registration.rb +31 -0
  15. data/lib/core/mixin/lookup.rb +50 -6
  16. data/lib/core/mixin/machine/ssh.rb +4 -4
  17. data/lib/core/plugin/cloud_action.rb +8 -1
  18. data/lib/core/plugin/configuration.rb +6 -7
  19. data/lib/core/plugin/fog_node.rb +7 -0
  20. data/lib/core/plugin/network.rb +31 -0
  21. data/lib/core/plugin/node.rb +182 -117
  22. data/lib/core/vagrant/provisioner/provisioner.rb +1 -1
  23. data/lib/nucleon/action/cloud/config.rb +259 -0
  24. data/lib/nucleon/action/cloud/images.rb +1 -1
  25. data/lib/nucleon/action/cloud/inspect.rb +11 -2
  26. data/lib/nucleon/action/cloud/machines.rb +1 -1
  27. data/lib/nucleon/action/cloud/regions.rb +1 -1
  28. data/lib/nucleon/action/cloud/settings.rb +185 -0
  29. data/lib/nucleon/action/node/IP.rb +1 -1
  30. data/lib/nucleon/action/node/bootstrap.rb +1 -1
  31. data/lib/nucleon/action/node/cache.rb +133 -0
  32. data/lib/nucleon/action/node/fact.rb +119 -0
  33. data/lib/nucleon/action/node/facts.rb +16 -16
  34. data/lib/nucleon/action/node/group.rb +115 -0
  35. data/lib/nucleon/action/node/groups.rb +33 -0
  36. data/lib/nucleon/action/node/identity.rb +75 -0
  37. data/lib/nucleon/action/node/lookup.rb +20 -7
  38. data/lib/nucleon/action/node/seed.rb +6 -6
  39. data/lib/nucleon/action/node/status.rb +76 -0
  40. data/lib/nucleon/action/plugin/create.rb +169 -0
  41. data/lib/nucleon/action/plugin/list.rb +69 -0
  42. data/lib/nucleon/action/plugin/template/nucleon.action.erb +56 -0
  43. data/lib/nucleon/action/plugins.rb +14 -0
  44. data/locales/en.yml +3 -0
  45. data/rdoc/site/0.5.0/CORL/Build.html +757 -0
  46. data/rdoc/site/0.5.0/CORL/Builder/Identity.html +569 -0
  47. data/rdoc/site/0.5.0/CORL/Builder/Package.html +576 -0
  48. data/rdoc/site/0.5.0/CORL/Builder.html +360 -0
  49. data/rdoc/site/0.5.0/CORL/Configuration/File.html +1148 -0
  50. data/rdoc/site/0.5.0/CORL/Configuration.html +359 -0
  51. data/rdoc/site/0.5.0/CORL/Errors.html +359 -0
  52. data/rdoc/site/0.5.0/CORL/Facade.html +899 -0
  53. data/rdoc/site/0.5.0/CORL/Machine/AWS.html +753 -0
  54. data/rdoc/site/0.5.0/CORL/Machine/Fog.html +1289 -0
  55. data/rdoc/site/0.5.0/CORL/Machine/Physical.html +1059 -0
  56. data/rdoc/site/0.5.0/CORL/Machine/Rackspace.html +534 -0
  57. data/rdoc/site/0.5.0/CORL/Machine/Vagrant.html +1320 -0
  58. data/rdoc/site/0.5.0/CORL/Machine.html +363 -0
  59. data/rdoc/site/0.5.0/CORL/Mixin/Action/Keypair.html +592 -0
  60. data/rdoc/site/0.5.0/CORL/Mixin/Action.html +359 -0
  61. data/rdoc/site/0.5.0/CORL/Mixin/Builder/Global.html +604 -0
  62. data/rdoc/site/0.5.0/CORL/Mixin/Builder/Instance.html +696 -0
  63. data/rdoc/site/0.5.0/CORL/Mixin/Builder.html +359 -0
  64. data/rdoc/site/0.5.0/CORL/Mixin/Lookup.html +1139 -0
  65. data/rdoc/site/0.5.0/CORL/Mixin/Machine/SSH.html +675 -0
  66. data/rdoc/site/0.5.0/CORL/Mixin/Machine.html +359 -0
  67. data/rdoc/site/0.5.0/CORL/Mixin/Macro/NetworkSettings.html +484 -0
  68. data/rdoc/site/0.5.0/CORL/Mixin/Macro.html +359 -0
  69. data/rdoc/site/0.5.0/CORL/Mixin.html +363 -0
  70. data/rdoc/site/0.5.0/CORL/Network/CORL.html +411 -0
  71. data/rdoc/site/0.5.0/CORL/Network.html +359 -0
  72. data/rdoc/site/0.5.0/CORL/Node/AWS.html +736 -0
  73. data/rdoc/site/0.5.0/CORL/Node/Fog.html +1212 -0
  74. data/rdoc/site/0.5.0/CORL/Node/Local.html +444 -0
  75. data/rdoc/site/0.5.0/CORL/Node/Rackspace.html +729 -0
  76. data/rdoc/site/0.5.0/CORL/Node/Vagrant.html +1476 -0
  77. data/rdoc/site/0.5.0/CORL/Node.html +363 -0
  78. data/rdoc/site/0.5.0/CORL/Plugin/Builder.html +500 -0
  79. data/rdoc/site/0.5.0/CORL/Plugin/Configuration.html +1271 -0
  80. data/rdoc/site/0.5.0/CORL/Plugin/Machine.html +1299 -0
  81. data/rdoc/site/0.5.0/CORL/Plugin/Network.html +1580 -0
  82. data/rdoc/site/0.5.0/CORL/Plugin/Node.html +4041 -0
  83. data/rdoc/site/0.5.0/CORL/Plugin/Provisioner.html +1115 -0
  84. data/rdoc/site/0.5.0/CORL/Plugin.html +649 -0
  85. data/rdoc/site/0.5.0/CORL/Provisioner/Puppetnode.html +1177 -0
  86. data/rdoc/site/0.5.0/CORL/Provisioner.html +359 -0
  87. data/rdoc/site/0.5.0/CORL/Util/Puppet/Resource.html +1058 -0
  88. data/rdoc/site/0.5.0/CORL/Util/Puppet/ResourceGroup.html +940 -0
  89. data/rdoc/site/0.5.0/CORL/Util/Puppet.html +1107 -0
  90. data/rdoc/site/0.5.0/CORL/Util.html +361 -0
  91. data/rdoc/site/0.5.0/CORL/Vagrant/Config.html +943 -0
  92. data/rdoc/site/0.5.0/CORL/Vagrant.html +438 -0
  93. data/rdoc/site/0.5.0/CORL.html +471 -0
  94. data/rdoc/site/0.5.0/Fog/Compute/AWS/Server.html +443 -0
  95. data/rdoc/site/0.5.0/Fog/Compute/AWS.html +365 -0
  96. data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2/Server.html +428 -0
  97. data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2.html +365 -0
  98. data/rdoc/site/0.5.0/Fog/Compute.html +360 -0
  99. data/rdoc/site/0.5.0/Fog.html +360 -0
  100. data/rdoc/site/0.5.0/Hiera/Backend.html +442 -0
  101. data/rdoc/site/0.5.0/Hiera/Corl_logger.html +469 -0
  102. data/rdoc/site/0.5.0/Hiera.html +366 -0
  103. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Create.html +538 -0
  104. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Hiera.html +566 -0
  105. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Images.html +572 -0
  106. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Inspect.html +524 -0
  107. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Machines.html +567 -0
  108. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Regions.html +567 -0
  109. data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Vagrantfile.html +515 -0
  110. data/rdoc/site/0.5.0/Nucleon/Action/Cloud.html +365 -0
  111. data/rdoc/site/0.5.0/Nucleon/Action/Node/Authorize.html +543 -0
  112. data/rdoc/site/0.5.0/Nucleon/Action/Node/Bootstrap.html +604 -0
  113. data/rdoc/site/0.5.0/Nucleon/Action/Node/Build.html +526 -0
  114. data/rdoc/site/0.5.0/Nucleon/Action/Node/Destroy.html +573 -0
  115. data/rdoc/site/0.5.0/Nucleon/Action/Node/Exec.html +530 -0
  116. data/rdoc/site/0.5.0/Nucleon/Action/Node/Facts.html +456 -0
  117. data/rdoc/site/0.5.0/Nucleon/Action/Node/IP.html +453 -0
  118. data/rdoc/site/0.5.0/Nucleon/Action/Node/Image.html +573 -0
  119. data/rdoc/site/0.5.0/Nucleon/Action/Node/Keypair.html +572 -0
  120. data/rdoc/site/0.5.0/Nucleon/Action/Node/Lookup.html +532 -0
  121. data/rdoc/site/0.5.0/Nucleon/Action/Node/Provision.html +553 -0
  122. data/rdoc/site/0.5.0/Nucleon/Action/Node/Reboot.html +573 -0
  123. data/rdoc/site/0.5.0/Nucleon/Action/Node/Revoke.html +541 -0
  124. data/rdoc/site/0.5.0/Nucleon/Action/Node/SSH.html +583 -0
  125. data/rdoc/site/0.5.0/Nucleon/Action/Node/Seed.html +602 -0
  126. data/rdoc/site/0.5.0/Nucleon/Action/Node/Spawn.html +675 -0
  127. data/rdoc/site/0.5.0/Nucleon/Action/Node/Start.html +573 -0
  128. data/rdoc/site/0.5.0/Nucleon/Action/Node/Stop.html +573 -0
  129. data/rdoc/site/0.5.0/Nucleon/Action/Node.html +376 -0
  130. data/rdoc/site/0.5.0/Nucleon/Action.html +383 -0
  131. data/rdoc/site/0.5.0/Nucleon/Config.html +377 -0
  132. data/rdoc/site/0.5.0/Nucleon/Event/Puppet.html +693 -0
  133. data/rdoc/site/0.5.0/Nucleon/Event.html +359 -0
  134. data/rdoc/site/0.5.0/Nucleon/Plugin/Base.html +365 -0
  135. data/rdoc/site/0.5.0/Nucleon/Plugin/CloudAction.html +838 -0
  136. data/rdoc/site/0.5.0/Nucleon/Plugin.html +360 -0
  137. data/rdoc/site/0.5.0/Nucleon/Template/Environment.html +548 -0
  138. data/rdoc/site/0.5.0/Nucleon/Template.html +359 -0
  139. data/rdoc/site/0.5.0/Nucleon.html +387 -0
  140. data/rdoc/site/0.5.0/Object.html +378 -0
  141. data/rdoc/site/0.5.0/Puppet/DataBinding/Corl.html +365 -0
  142. data/rdoc/site/0.5.0/Puppet/DataBinding.html +358 -0
  143. data/rdoc/site/0.5.0/Puppet/Indirector/Corl.html +477 -0
  144. data/rdoc/site/0.5.0/Puppet/Indirector.html +358 -0
  145. data/rdoc/site/0.5.0/Puppet/Parser/Functions.html +500 -0
  146. data/rdoc/site/0.5.0/Puppet/Parser.html +358 -0
  147. data/rdoc/site/0.5.0/Puppet.html +358 -0
  148. data/rdoc/site/0.5.0/README_rdoc.html +360 -0
  149. data/rdoc/site/0.5.0/Vagrant/Config/Loader.html +419 -0
  150. data/rdoc/site/0.5.0/Vagrant/Config.html +359 -0
  151. data/rdoc/site/0.5.0/Vagrant/Vagrantfile.html +412 -0
  152. data/rdoc/site/0.5.0/Vagrant.html +366 -0
  153. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/DeleteCache.html +422 -0
  154. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/InitKeys.html +428 -0
  155. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/LinkNetwork.html +426 -0
  156. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action.html +361 -0
  157. data/rdoc/site/0.5.0/VagrantPlugins/CORL/BaseAction.html +511 -0
  158. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command/Launcher.html +553 -0
  159. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command.html +359 -0
  160. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config/CORL.html +752 -0
  161. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config.html +359 -0
  162. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Plugin.html +365 -0
  163. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner/CORL.html +556 -0
  164. data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner.html +359 -0
  165. data/rdoc/site/0.5.0/VagrantPlugins/CORL.html +366 -0
  166. data/rdoc/site/0.5.0/VagrantPlugins.html +366 -0
  167. data/rdoc/site/0.5.0/created.rid +103 -0
  168. data/rdoc/site/0.5.0/images/add.png +0 -0
  169. data/rdoc/site/0.5.0/images/brick.png +0 -0
  170. data/rdoc/site/0.5.0/images/brick_link.png +0 -0
  171. data/rdoc/site/0.5.0/images/bug.png +0 -0
  172. data/rdoc/site/0.5.0/images/bullet_black.png +0 -0
  173. data/rdoc/site/0.5.0/images/bullet_toggle_minus.png +0 -0
  174. data/rdoc/site/0.5.0/images/bullet_toggle_plus.png +0 -0
  175. data/rdoc/site/0.5.0/images/date.png +0 -0
  176. data/rdoc/site/0.5.0/images/delete.png +0 -0
  177. data/rdoc/site/0.5.0/images/find.png +0 -0
  178. data/rdoc/site/0.5.0/images/loadingAnimation.gif +0 -0
  179. data/rdoc/site/0.5.0/images/macFFBgHack.png +0 -0
  180. data/rdoc/site/0.5.0/images/package.png +0 -0
  181. data/rdoc/site/0.5.0/images/page_green.png +0 -0
  182. data/rdoc/site/0.5.0/images/page_white_text.png +0 -0
  183. data/rdoc/site/0.5.0/images/page_white_width.png +0 -0
  184. data/rdoc/site/0.5.0/images/plugin.png +0 -0
  185. data/rdoc/site/0.5.0/images/ruby.png +0 -0
  186. data/rdoc/site/0.5.0/images/tag_blue.png +0 -0
  187. data/rdoc/site/0.5.0/images/tag_green.png +0 -0
  188. data/rdoc/site/0.5.0/images/transparent.png +0 -0
  189. data/rdoc/site/0.5.0/images/wrench.png +0 -0
  190. data/rdoc/site/0.5.0/images/wrench_orange.png +0 -0
  191. data/rdoc/site/0.5.0/images/zoom.png +0 -0
  192. data/rdoc/site/0.5.0/index.html +359 -0
  193. data/rdoc/site/0.5.0/js/darkfish.js +155 -0
  194. data/rdoc/site/0.5.0/js/jquery.js +18 -0
  195. data/rdoc/site/0.5.0/js/navigation.js +142 -0
  196. data/rdoc/site/0.5.0/js/search.js +94 -0
  197. data/rdoc/site/0.5.0/js/search_index.js +1 -0
  198. data/rdoc/site/0.5.0/js/searcher.js +228 -0
  199. data/rdoc/site/0.5.0/rdoc.css +543 -0
  200. data/rdoc/site/0.5.0/table_of_contents.html +1797 -0
  201. metadata +171 -3
  202. data/lib/nucleon/action/cloud/hiera.rb +0 -61
@@ -44,7 +44,7 @@ module SSH
44
44
  end
45
45
 
46
46
  rescue => error
47
- ui.warn(error)
47
+ warn(error, { :i18n => false })
48
48
  success = false
49
49
  end
50
50
  success
@@ -64,7 +64,7 @@ module SSH
64
64
  success = true
65
65
  end
66
66
  rescue => error
67
- ui.error(error.message)
67
+ error(error.message, { :i18n => false })
68
68
  end
69
69
 
70
70
  success
@@ -84,7 +84,7 @@ module SSH
84
84
  success = true
85
85
  end
86
86
  rescue => error
87
- ui.error(error.message)
87
+ error(error.message, { :i18n => false })
88
88
  end
89
89
 
90
90
  success
@@ -96,7 +96,7 @@ module SSH
96
96
  config = Config.ensure(options)
97
97
  results = nil
98
98
 
99
- if commands
99
+ if commands && commands = commands.clone
100
100
  if init_ssh_session
101
101
  results = Util::SSH.exec(node.public_ip, node.user, commands) do |type, command, data|
102
102
  code.call(type, command, data) if code
@@ -147,7 +147,7 @@ class CloudAction < CORL.plugin_class(:nucleon, :action)
147
147
  if validate(node, network)
148
148
  yield(node, network) if block_given?
149
149
  else
150
- puts "\n" + I18n.t('corl.core.exec.help.usage') + ': ' + help + "\n" unless quiet?
150
+ puts "\n" + I18n.t('nucleon.core.exec.help.usage') + ': ' + help + "\n" unless quiet?
151
151
  myself.status = code.validation_failed
152
152
  end
153
153
  end
@@ -198,6 +198,13 @@ class CloudAction < CORL.plugin_class(:nucleon, :action)
198
198
  myself.status = code.node_failure
199
199
  end
200
200
  end
201
+
202
+ #-----------------------------------------------------------------------------
203
+ # Utilities
204
+
205
+ def sanitize_remote(network, remote)
206
+ remote && network.remote(remote) ? remote : nil
207
+ end
201
208
  end
202
209
  end
203
210
  end
@@ -113,22 +113,22 @@ class Configuration < CORL.plugin_class(:nucleon, :base)
113
113
  #-----------------------------------------------------------------------------
114
114
 
115
115
  def set(keys, value = '', options = {})
116
- super(keys, value)
117
- save(options) if autosave
116
+ super(keys, value, true)
117
+ save(options) if initialized? && autosave
118
118
  end
119
119
 
120
120
  #---
121
121
 
122
122
  def delete(keys, options = {})
123
123
  super(keys)
124
- save(options) if autosave
124
+ save(options) if initialized? && autosave
125
125
  end
126
126
 
127
127
  #---
128
128
 
129
129
  def clear(options = {})
130
130
  super
131
- save(options) if autosave
131
+ save(options) if initialized? && autosave
132
132
  end
133
133
 
134
134
  #-----------------------------------------------------------------------------
@@ -165,15 +165,14 @@ class Configuration < CORL.plugin_class(:nucleon, :base)
165
165
  config.clear if method_config.get(:override, false)
166
166
 
167
167
  properties = Config.new
168
- yield(method_config, properties) if block_given?
168
+ success = yield(method_config, properties) if block_given?
169
169
 
170
- unless properties.export.empty?
170
+ if success && ! properties.export.empty?
171
171
  logger.debug("Source configuration parsed properties: #{properties}")
172
172
 
173
173
  extension(:load_process, { :properties => properties, :config => method_config })
174
174
  config.import(properties, method_config)
175
175
  end
176
- success = true
177
176
  end
178
177
  else
179
178
  logger.warn("Loading of source configuration failed")
@@ -210,6 +210,13 @@ class Fog < CORL.plugin_class(:CORL, :node)
210
210
  yield(op, config) if block_given?
211
211
  end
212
212
  end
213
+
214
+ #-----------------------------------------------------------------------------
215
+ # Utilities
216
+
217
+ def filter_output(type, data)
218
+ super
219
+ end
213
220
  end
214
221
  end
215
222
  end
@@ -76,6 +76,12 @@ class Network < CORL.plugin_class(:nucleon, :base)
76
76
 
77
77
  #---
78
78
 
79
+ def key_directory
80
+ File.join(directory, 'keys')
81
+ end
82
+
83
+ #---
84
+
79
85
  def build_directory
80
86
  File.join(directory, 'build')
81
87
  end
@@ -85,6 +91,13 @@ class Network < CORL.plugin_class(:nucleon, :base)
85
91
  def key_cache_directory
86
92
  File.join(build_directory, 'keys')
87
93
  end
94
+
95
+ #---
96
+
97
+ def config_directory
98
+ File.join(directory, 'config')
99
+ end
100
+
88
101
  #---
89
102
 
90
103
  def cache
@@ -220,6 +233,22 @@ class Network < CORL.plugin_class(:nucleon, :base)
220
233
  @build
221
234
  end
222
235
 
236
+ #---
237
+
238
+ def create_builder(name, provider, options = {})
239
+ CORL.create_plugin(:CORL, :builder, provider, extended_config(name, options).import({ :meta => { :parent => myself }}))
240
+ end
241
+
242
+ #---
243
+
244
+ def identity_builder(options = {})
245
+ create_builder(:network_identity_builder, :identity, options)
246
+ end
247
+
248
+ def package_builder(name, options = {})
249
+ create_builder(:network_package_builder, :package, options)
250
+ end
251
+
223
252
  #-----------------------------------------------------------------------------
224
253
  # Operations
225
254
 
@@ -408,6 +437,8 @@ class Network < CORL.plugin_class(:nucleon, :base)
408
437
  def batch(node_references, default_provider = nil, parallel = true, &code)
409
438
  success = true
410
439
 
440
+ node_references = array(node_references.clone)
441
+
411
442
  if has_nodes? && ! node_references.empty?
412
443
  # Execute action on selected nodes
413
444
  nodes = nodes_by_reference(node_references, default_provider)
@@ -30,7 +30,7 @@ class Node < CORL.plugin_class(:nucleon, :base)
30
30
  end
31
31
  if result
32
32
  result = result.first
33
- alert(result.errors) unless result.errors.empty?
33
+ warn(result.errors, { :i18n => false }) unless result.errors.empty?
34
34
  end
35
35
  result
36
36
  end
@@ -85,47 +85,6 @@ class Node < CORL.plugin_class(:nucleon, :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
-
123
- def hiera_override_dir
124
- network.hiera_override_dir
125
- end
126
-
127
- #---
128
-
129
88
  def keypair
130
89
  @keypair
131
90
  end
@@ -339,6 +298,18 @@ class Node < CORL.plugin_class(:nucleon, :base)
339
298
  search(:facts, {}, :hash)
340
299
  end
341
300
 
301
+ def ensure_custom_facts(facts)
302
+ hash(facts).each do |name, value|
303
+ set_setting([ :facts, name ], value)
304
+ end
305
+ end
306
+
307
+ def remove_custom_facts(*facts)
308
+ facts.each do |name|
309
+ delete_setting([ :facts, name ])
310
+ end
311
+ end
312
+
342
313
  #---
343
314
 
344
315
  def profiles=profiles
@@ -407,7 +378,135 @@ class Node < CORL.plugin_class(:nucleon, :base)
407
378
  yield(config) if block_given?
408
379
  config
409
380
  end
410
-
381
+
382
+ #-----------------------------------------------------------------------------
383
+ # Machine information
384
+
385
+ def fact_var
386
+ @facts
387
+ end
388
+
389
+ def fact_var=facts
390
+ @facts = facts
391
+ end
392
+
393
+ #---
394
+
395
+ def facts(reset = false, clone = true)
396
+ if reset || fact_var.nil?
397
+ default_facts = extended_config(:hiera_default_facts, {
398
+ :fqdn => hostname,
399
+ :hostname => hostname.gsub(/\..*$/, ''),
400
+ :corl_provider => plugin_provider.to_s
401
+ })
402
+
403
+ unless local?
404
+ result = run.node_facts({ :quiet => true })
405
+
406
+ if result.status == code.success
407
+ node_facts = Util::Data.symbol_map(Util::Data.parse_json(result.errors))
408
+ end
409
+ end
410
+ unless node_facts
411
+ node_facts = local? ? Util::Data.merge([ CORL.facts, custom_facts ]) : custom_facts
412
+ end
413
+
414
+ self.fact_var = Config.new(node_facts).defaults(default_facts).export
415
+ end
416
+ return fact_var.clone if clone
417
+ fact_var
418
+ end
419
+
420
+ #---
421
+
422
+ def create_facts_post(data, names)
423
+ fact_values = {}
424
+ names.each do |name|
425
+ name = name.to_sym
426
+ fact_values[name] = data[name]
427
+ end
428
+ ensure_custom_facts(fact_values)
429
+ data
430
+ end
431
+
432
+ #---
433
+
434
+ def delete_facts_post(data, old_data)
435
+ remove_custom_facts(*old_data.keys)
436
+ data
437
+ end
438
+
439
+ #---
440
+
441
+ def hiera_var
442
+ @hiera
443
+ end
444
+
445
+ def hiera_var=hiera
446
+ @hiera = hiera
447
+ end
448
+
449
+ #---
450
+
451
+ def hiera_override_dir
452
+ network.hiera_override_dir
453
+ end
454
+
455
+ #---
456
+
457
+ def lookup(property, default = nil, options = {})
458
+ unless local?
459
+ config = Config.ensure(options).import({ :property => property, :quiet => true })
460
+ result = run.node_lookup(config)
461
+
462
+ if result.status == code.success
463
+ return Util::Data.value(Util::Data.parse_json(result.errors), default)
464
+ end
465
+ return default
466
+ end
467
+ options[:hiera_scope] = Util::Data.prefix('::', facts, '')
468
+ lookup_base(property, default, options)
469
+ end
470
+
471
+ #---
472
+
473
+ def remote_cache_setting(keys, default = nil, format = false)
474
+ cache_id = keys.flatten.join('.')
475
+ result = run.node_cache({ :name => cache_id })
476
+
477
+ if result.status == code.success
478
+ value = Util::Data.value(Util::Data.parse_json(result.errors), default)
479
+ else
480
+ value = default
481
+ end
482
+ filter(value, format)
483
+ end
484
+
485
+ #---
486
+
487
+ def set_remote_cache_setting(keys, value)
488
+ run.node_cache({
489
+ :name => keys.flatten.join('.'),
490
+ :value => Util::Data.to_json(value, false),
491
+ :json => true
492
+ }).status == code.success
493
+ end
494
+
495
+ #---
496
+
497
+ def delete_remote_cache_setting(keys)
498
+ run.node_cache({
499
+ :name => keys.flatten.join('.'),
500
+ :delete => true
501
+ }).status == code.success
502
+ end
503
+
504
+ #---
505
+
506
+ def clear_remote_cache
507
+ run.node_cache({ :clear => true }).status == code.success
508
+ end
509
+
411
510
  #-----------------------------------------------------------------------------
412
511
  # Machine operations
413
512
 
@@ -416,6 +515,7 @@ class Node < CORL.plugin_class(:nucleon, :base)
416
515
  success = true
417
516
 
418
517
  # TODO: Figure out what's going on with the parallel implementation here.
518
+ parallel_original = ENV['NUCLEON_NO_PARALLEL']
419
519
  ENV['NUCLEON_NO_PARALLEL'] = 'true'
420
520
 
421
521
  status = parallel(:build_provider, network.builders, config)
@@ -429,7 +529,7 @@ class Node < CORL.plugin_class(:nucleon, :base)
429
529
  myself.build_time = Time.now.to_s if success
430
530
 
431
531
  if config.delete(:save, true)
432
- ui.success("Saving successful build")
532
+ success("Saving successful build", { :i18n => false })
433
533
 
434
534
  success = save(extended_config(:build, {
435
535
  :message => config.get(:message, "Built #{plugin_provider} node: #{plugin_name}"),
@@ -439,24 +539,23 @@ class Node < CORL.plugin_class(:nucleon, :base)
439
539
  end
440
540
  end
441
541
 
442
- ENV['NUCLEON_NO_PARALLEL'] = nil
443
-
542
+ ENV['NUCLEON_NO_PARALLEL'] = parallel_original
444
543
  success
445
544
  end
446
545
 
447
546
  def build_provider(provider, plugin, config)
448
- ui.info("Building #{provider} components")
547
+ info("Building #{provider} components", { :i18n => false })
449
548
  plugin.build(myself, config)
450
549
  end
451
550
 
452
551
  def build_provisioners(provider, collection, config)
453
- ui.info("Building #{provider} provisioner collection")
552
+ info("Building #{provider} provisioner collection", { :i18n => false })
454
553
  status = parallel(:build_provisioner, collection, provider, config)
455
554
  status.values.include?(false) ? false : true
456
555
  end
457
556
 
458
557
  def build_provisioner(name, plugin, provider, config)
459
- ui.info("Building #{provider} #{name} provisioner components")
558
+ info("Building #{provider} #{name} provisioner components", { :i18n => false })
460
559
  plugin.build(myself, config)
461
560
  end
462
561
 
@@ -577,18 +676,18 @@ class Node < CORL.plugin_class(:nucleon, :base)
577
676
  if extension_check(:download, hook_config)
578
677
  logger.info("Downloading from #{plugin_name}")
579
678
 
580
- render("Starting download of #{remote_path} to #{local_path}")
679
+ info("Starting download of #{remote_path} to #{local_path}", { :i18n => false })
581
680
  yield(:config, hook_config) if block_given?
582
681
 
583
682
  active_machine = local? ? local_machine : machine
584
683
 
585
684
  success = active_machine.download(remote_path, local_path, config.export) do |name, received, total|
586
- render("#{name}: Sent #{received} of #{total}")
685
+ info("#{name}: Sent #{received} of #{total}", { :i18n => false })
587
686
  yield(:progress, { :name => name, :received => received, :total => total })
588
687
  end
589
688
 
590
689
  if success && block_given?
591
- render("Successfully finished download of #{remote_path} to #{local_path}")
690
+ info("Successfully finished download of #{remote_path} to #{local_path}", { :i18n => false })
592
691
  process_success = yield(:process, hook_config)
593
692
  success = process_success if process_success == false
594
693
  end
@@ -615,18 +714,18 @@ class Node < CORL.plugin_class(:nucleon, :base)
615
714
  if extension_check(:upload, hook_config)
616
715
  logger.info("Uploading to #{plugin_name}")
617
716
 
618
- render("Starting upload of #{local_path} to #{remote_path}")
717
+ info("Starting upload of #{local_path} to #{remote_path}", { :i18n => false })
619
718
  yield(:config, hook_config) if block_given?
620
719
 
621
720
  active_machine = local? ? local_machine : machine
622
721
 
623
722
  success = active_machine.upload(local_path, remote_path, config.export) do |name, sent, total|
624
- render("#{name}: Sent #{sent} of #{total}")
723
+ info("#{name}: Sent #{sent} of #{total}", { :i18n => false })
625
724
  yield(:progress, { :name => name, :sent => sent, :total => total })
626
725
  end
627
726
 
628
727
  if success && block_given?
629
- render("Successfully finished upload of #{local_path} to #{remote_path}")
728
+ info("Successfully finished upload of #{local_path} to #{remote_path}", { :i18n => false })
630
729
  process_success = yield(:process, hook_config)
631
730
  success = process_success if process_success == false
632
731
  end
@@ -690,24 +789,25 @@ class Node < CORL.plugin_class(:nucleon, :base)
690
789
 
691
790
  if local? && local_machine
692
791
  active_machine = local_machine
693
-
694
- config[:info_prefix] = "[#{hostname}] "
695
- config[:error_prefix] = "[#{hostname}] "
696
792
  else
697
793
  active_machine = machine
698
794
  end
699
795
 
700
796
  if commands = config.get(:commands, nil)
797
+ quiet = config.get(:quiet, false)
798
+
701
799
  begin
702
800
  test = active_machine.exec(commands, config.export) do |type, command, data|
703
- unless local?
704
- if type == :error
705
- alert(filter_output(type, data))
706
- else
707
- render(filter_output(type, data))
801
+ unless quiet
802
+ unless local?
803
+ if type == :error
804
+ warn(filter_output(type, data), { :i18n => false })
805
+ else
806
+ info(filter_output(type, data), { :i18n => false })
807
+ end
708
808
  end
709
- end
710
- yield(:progress, { :type => type, :command => command, :data => data }) if block_given?
809
+ yield(:progress, { :type => type, :command => command, :data => data }) if block_given?
810
+ end
711
811
  end
712
812
  results = test if test
713
813
 
@@ -750,11 +850,13 @@ class Node < CORL.plugin_class(:nucleon, :base)
750
850
  #---
751
851
 
752
852
  def command(command, options = {})
753
- config = Config.ensure(options)
754
- as_admin = config.delete(:as_admin, false)
853
+ config = Config.ensure(options)
854
+ as_admin = config.delete(:as_admin, false)
855
+ remove_command = false
755
856
 
756
857
  unless command.is_a?(CORL::Plugin::Command)
757
- command = CORL.command(Config.new({ :command => command }).import(config), :bash)
858
+ command = CORL.command(Config.new({ :command => command }).import(config), :bash)
859
+ remove_command = true
758
860
  end
759
861
 
760
862
  admin_command = ''
@@ -763,11 +865,13 @@ class Node < CORL.plugin_class(:nucleon, :base)
763
865
  admin_command = extension_set(:admin_command, admin_command, config)
764
866
  end
765
867
 
766
- results = exec({ :commands => [ "#{admin_command} #{command.to_s}".strip ] }) do |op, data|
868
+ config[:commands] = [ "#{admin_command} #{command.to_s}".strip ]
869
+
870
+ results = exec(config) do |op, data|
767
871
  yield(op, data) if block_given?
768
872
  end
769
873
 
770
- CORL.remove_plugin(command)
874
+ CORL.remove_plugin(command) if remove_command
771
875
  results.first
772
876
  end
773
877
 
@@ -790,7 +894,8 @@ class Node < CORL.plugin_class(:nucleon, :base)
790
894
  :data => { :encoded => encoded_config }
791
895
  })
792
896
 
793
- result = command(:corl, { :subcommand => action_config, :as_admin => true }) do |op, data|
897
+ quiet = config.get(:quiet, false)
898
+ result = command(:corl, { :subcommand => action_config, :as_admin => true, :quiet => quiet }) do |op, data|
794
899
  yield(op, data) if block_given?
795
900
  end
796
901
 
@@ -820,9 +925,6 @@ class Node < CORL.plugin_class(:nucleon, :base)
820
925
 
821
926
  if local? && local_machine
822
927
  active_machine = local_machine
823
-
824
- config[:info_prefix] = "[#{hostname}] "
825
- config[:error_prefix] = "[#{hostname}] "
826
928
  else
827
929
  active_machine = machine
828
930
  end
@@ -842,49 +944,6 @@ class Node < CORL.plugin_class(:nucleon, :base)
842
944
  status == code.success
843
945
  end
844
946
 
845
- #---
846
-
847
- def lookup_facts
848
- if ! local? && bootstrap_script
849
- result = run.facts
850
-
851
- if result.status == code.success
852
- return Util::Data.symbol_map(Util::Data.parse_json(result.output))
853
- end
854
- end
855
- local? ? Util::Data.merge([ CORL.facts, custom_facts ]) : custom_facts
856
- end
857
-
858
- #---
859
-
860
- def lookup_config(property, default = nil, options = {})
861
- if ! local? && bootstrap_script
862
- config = Config.ensure(options).import({ :property => property })
863
- result = run.lookup(config)
864
-
865
- if result.status == code.success
866
- return Util::Data.value(Util::Data.parse_json(result.output), default)
867
- end
868
- return default
869
- end
870
- options[:hiera_scope] = Util::Data.prefix('::', facts, '')
871
- lookup(property, default, options)
872
- end
873
-
874
- #---
875
-
876
- def lookup_array(property, default = [], options = {})
877
- config = Config.ensure(options).import({ :context => :array })
878
- lookup_config(property, default, config)
879
- end
880
-
881
- #---
882
-
883
- def lookup_hash(property, default = {}, options = {})
884
- config = Config.ensure(options).import({ :context => :hash })
885
- lookup_config(property, default, config)
886
- end
887
-
888
947
  #---
889
948
 
890
949
  def bootstrap(local_path, options = {})
@@ -1276,6 +1335,12 @@ class Node < CORL.plugin_class(:nucleon, :base)
1276
1335
  #---
1277
1336
 
1278
1337
  def filter_output(type, data)
1338
+ if type == :output
1339
+ # Hide redundant Facter output
1340
+ if data =~ /^Already evaluated [a-z]+ at [^,]+, reevaluating anyways$/
1341
+ data = ''
1342
+ end
1343
+ end
1279
1344
  data
1280
1345
  end
1281
1346
 
@@ -50,7 +50,7 @@ class CORL < ::Vagrant.plugin("2", :provisioner)
50
50
  :dry_run => config.dry_run
51
51
  }).export))
52
52
 
53
- node.ui.warn("CORL provisioner failed") unless success
53
+ node.warn("CORL provisioner failed", { :i18n => false }) unless success
54
54
  end
55
55
  end
56
56
  end