corl 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/06_puppet.sh +1 -1
- data/corl.gemspec +171 -3
- data/lib/CORL/builder/identity.rb +6 -3
- data/lib/CORL/builder/package.rb +3 -3
- data/lib/CORL/configuration/file.rb +21 -7
- data/lib/CORL/machine/vagrant.rb +3 -3
- data/lib/CORL/node/vagrant.rb +2 -5
- data/lib/CORL/provisioner/puppetnode.rb +8 -8
- data/lib/core/facade.rb +7 -3
- data/lib/core/mixin/action/keypair.rb +3 -3
- data/lib/core/mixin/action/registration.rb +31 -0
- data/lib/core/mixin/lookup.rb +50 -6
- data/lib/core/mixin/machine/ssh.rb +4 -4
- data/lib/core/plugin/cloud_action.rb +8 -1
- data/lib/core/plugin/configuration.rb +6 -7
- data/lib/core/plugin/fog_node.rb +7 -0
- data/lib/core/plugin/network.rb +31 -0
- data/lib/core/plugin/node.rb +182 -117
- data/lib/core/vagrant/provisioner/provisioner.rb +1 -1
- data/lib/nucleon/action/cloud/config.rb +259 -0
- data/lib/nucleon/action/cloud/images.rb +1 -1
- data/lib/nucleon/action/cloud/inspect.rb +11 -2
- data/lib/nucleon/action/cloud/machines.rb +1 -1
- data/lib/nucleon/action/cloud/regions.rb +1 -1
- data/lib/nucleon/action/cloud/settings.rb +185 -0
- data/lib/nucleon/action/node/IP.rb +1 -1
- data/lib/nucleon/action/node/bootstrap.rb +1 -1
- data/lib/nucleon/action/node/cache.rb +133 -0
- data/lib/nucleon/action/node/fact.rb +119 -0
- data/lib/nucleon/action/node/facts.rb +16 -16
- data/lib/nucleon/action/node/group.rb +115 -0
- data/lib/nucleon/action/node/groups.rb +33 -0
- data/lib/nucleon/action/node/identity.rb +75 -0
- data/lib/nucleon/action/node/lookup.rb +20 -7
- data/lib/nucleon/action/node/seed.rb +6 -6
- data/lib/nucleon/action/node/status.rb +76 -0
- data/lib/nucleon/action/plugin/create.rb +169 -0
- data/lib/nucleon/action/plugin/list.rb +69 -0
- data/lib/nucleon/action/plugin/template/nucleon.action.erb +56 -0
- data/lib/nucleon/action/plugins.rb +14 -0
- data/locales/en.yml +3 -0
- data/rdoc/site/0.5.0/CORL/Build.html +757 -0
- data/rdoc/site/0.5.0/CORL/Builder/Identity.html +569 -0
- data/rdoc/site/0.5.0/CORL/Builder/Package.html +576 -0
- data/rdoc/site/0.5.0/CORL/Builder.html +360 -0
- data/rdoc/site/0.5.0/CORL/Configuration/File.html +1148 -0
- data/rdoc/site/0.5.0/CORL/Configuration.html +359 -0
- data/rdoc/site/0.5.0/CORL/Errors.html +359 -0
- data/rdoc/site/0.5.0/CORL/Facade.html +899 -0
- data/rdoc/site/0.5.0/CORL/Machine/AWS.html +753 -0
- data/rdoc/site/0.5.0/CORL/Machine/Fog.html +1289 -0
- data/rdoc/site/0.5.0/CORL/Machine/Physical.html +1059 -0
- data/rdoc/site/0.5.0/CORL/Machine/Rackspace.html +534 -0
- data/rdoc/site/0.5.0/CORL/Machine/Vagrant.html +1320 -0
- data/rdoc/site/0.5.0/CORL/Machine.html +363 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Action/Keypair.html +592 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Action.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder/Global.html +604 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder/Instance.html +696 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Lookup.html +1139 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Machine/SSH.html +675 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Machine.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Macro/NetworkSettings.html +484 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Macro.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin.html +363 -0
- data/rdoc/site/0.5.0/CORL/Network/CORL.html +411 -0
- data/rdoc/site/0.5.0/CORL/Network.html +359 -0
- data/rdoc/site/0.5.0/CORL/Node/AWS.html +736 -0
- data/rdoc/site/0.5.0/CORL/Node/Fog.html +1212 -0
- data/rdoc/site/0.5.0/CORL/Node/Local.html +444 -0
- data/rdoc/site/0.5.0/CORL/Node/Rackspace.html +729 -0
- data/rdoc/site/0.5.0/CORL/Node/Vagrant.html +1476 -0
- data/rdoc/site/0.5.0/CORL/Node.html +363 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Builder.html +500 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Configuration.html +1271 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Machine.html +1299 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Network.html +1580 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Node.html +4041 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Provisioner.html +1115 -0
- data/rdoc/site/0.5.0/CORL/Plugin.html +649 -0
- data/rdoc/site/0.5.0/CORL/Provisioner/Puppetnode.html +1177 -0
- data/rdoc/site/0.5.0/CORL/Provisioner.html +359 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet/Resource.html +1058 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet/ResourceGroup.html +940 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet.html +1107 -0
- data/rdoc/site/0.5.0/CORL/Util.html +361 -0
- data/rdoc/site/0.5.0/CORL/Vagrant/Config.html +943 -0
- data/rdoc/site/0.5.0/CORL/Vagrant.html +438 -0
- data/rdoc/site/0.5.0/CORL.html +471 -0
- data/rdoc/site/0.5.0/Fog/Compute/AWS/Server.html +443 -0
- data/rdoc/site/0.5.0/Fog/Compute/AWS.html +365 -0
- data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2/Server.html +428 -0
- data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2.html +365 -0
- data/rdoc/site/0.5.0/Fog/Compute.html +360 -0
- data/rdoc/site/0.5.0/Fog.html +360 -0
- data/rdoc/site/0.5.0/Hiera/Backend.html +442 -0
- data/rdoc/site/0.5.0/Hiera/Corl_logger.html +469 -0
- data/rdoc/site/0.5.0/Hiera.html +366 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Create.html +538 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Hiera.html +566 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Images.html +572 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Inspect.html +524 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Machines.html +567 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Regions.html +567 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Vagrantfile.html +515 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud.html +365 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Authorize.html +543 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Bootstrap.html +604 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Build.html +526 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Destroy.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Exec.html +530 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Facts.html +456 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/IP.html +453 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Image.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Keypair.html +572 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Lookup.html +532 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Provision.html +553 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Reboot.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Revoke.html +541 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/SSH.html +583 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Seed.html +602 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Spawn.html +675 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Start.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Stop.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node.html +376 -0
- data/rdoc/site/0.5.0/Nucleon/Action.html +383 -0
- data/rdoc/site/0.5.0/Nucleon/Config.html +377 -0
- data/rdoc/site/0.5.0/Nucleon/Event/Puppet.html +693 -0
- data/rdoc/site/0.5.0/Nucleon/Event.html +359 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin/Base.html +365 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin/CloudAction.html +838 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin.html +360 -0
- data/rdoc/site/0.5.0/Nucleon/Template/Environment.html +548 -0
- data/rdoc/site/0.5.0/Nucleon/Template.html +359 -0
- data/rdoc/site/0.5.0/Nucleon.html +387 -0
- data/rdoc/site/0.5.0/Object.html +378 -0
- data/rdoc/site/0.5.0/Puppet/DataBinding/Corl.html +365 -0
- data/rdoc/site/0.5.0/Puppet/DataBinding.html +358 -0
- data/rdoc/site/0.5.0/Puppet/Indirector/Corl.html +477 -0
- data/rdoc/site/0.5.0/Puppet/Indirector.html +358 -0
- data/rdoc/site/0.5.0/Puppet/Parser/Functions.html +500 -0
- data/rdoc/site/0.5.0/Puppet/Parser.html +358 -0
- data/rdoc/site/0.5.0/Puppet.html +358 -0
- data/rdoc/site/0.5.0/README_rdoc.html +360 -0
- data/rdoc/site/0.5.0/Vagrant/Config/Loader.html +419 -0
- data/rdoc/site/0.5.0/Vagrant/Config.html +359 -0
- data/rdoc/site/0.5.0/Vagrant/Vagrantfile.html +412 -0
- data/rdoc/site/0.5.0/Vagrant.html +366 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/DeleteCache.html +422 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/InitKeys.html +428 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/LinkNetwork.html +426 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action.html +361 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/BaseAction.html +511 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command/Launcher.html +553 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config/CORL.html +752 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Plugin.html +365 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner/CORL.html +556 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL.html +366 -0
- data/rdoc/site/0.5.0/VagrantPlugins.html +366 -0
- data/rdoc/site/0.5.0/created.rid +103 -0
- data/rdoc/site/0.5.0/images/add.png +0 -0
- data/rdoc/site/0.5.0/images/brick.png +0 -0
- data/rdoc/site/0.5.0/images/brick_link.png +0 -0
- data/rdoc/site/0.5.0/images/bug.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_black.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.5.0/images/date.png +0 -0
- data/rdoc/site/0.5.0/images/delete.png +0 -0
- data/rdoc/site/0.5.0/images/find.png +0 -0
- data/rdoc/site/0.5.0/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.5.0/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.5.0/images/package.png +0 -0
- data/rdoc/site/0.5.0/images/page_green.png +0 -0
- data/rdoc/site/0.5.0/images/page_white_text.png +0 -0
- data/rdoc/site/0.5.0/images/page_white_width.png +0 -0
- data/rdoc/site/0.5.0/images/plugin.png +0 -0
- data/rdoc/site/0.5.0/images/ruby.png +0 -0
- data/rdoc/site/0.5.0/images/tag_blue.png +0 -0
- data/rdoc/site/0.5.0/images/tag_green.png +0 -0
- data/rdoc/site/0.5.0/images/transparent.png +0 -0
- data/rdoc/site/0.5.0/images/wrench.png +0 -0
- data/rdoc/site/0.5.0/images/wrench_orange.png +0 -0
- data/rdoc/site/0.5.0/images/zoom.png +0 -0
- data/rdoc/site/0.5.0/index.html +359 -0
- data/rdoc/site/0.5.0/js/darkfish.js +155 -0
- data/rdoc/site/0.5.0/js/jquery.js +18 -0
- data/rdoc/site/0.5.0/js/navigation.js +142 -0
- data/rdoc/site/0.5.0/js/search.js +94 -0
- data/rdoc/site/0.5.0/js/search_index.js +1 -0
- data/rdoc/site/0.5.0/js/searcher.js +228 -0
- data/rdoc/site/0.5.0/rdoc.css +543 -0
- data/rdoc/site/0.5.0/table_of_contents.html +1797 -0
- metadata +171 -3
- 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
|
-
|
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
|
-
|
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
|
-
|
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('
|
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
|
-
|
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")
|
data/lib/core/plugin/fog_node.rb
CHANGED
@@ -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
|
data/lib/core/plugin/network.rb
CHANGED
@@ -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)
|
data/lib/core/plugin/node.rb
CHANGED
@@ -30,7 +30,7 @@ class Node < CORL.plugin_class(:nucleon, :base)
|
|
30
30
|
end
|
31
31
|
if result
|
32
32
|
result = result.first
|
33
|
-
|
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
|
-
|
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'] =
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
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
|
-
|
710
|
-
|
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
|
754
|
-
as_admin
|
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
|
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
|
-
|
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
|
-
|
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
|
|