Class: Ridley::Bootstrapper
- Inherits:
-
Object
- Object
- Ridley::Bootstrapper
show all
- Includes:
- Celluloid, Logging
- Defined in:
- lib/ridley/bootstrapper.rb,
lib/ridley/bootstrapper/context.rb
Overview
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
logger, #logger, set_logger
Constructor Details
#initialize(hosts, options = {}) ⇒ Bootstrapper
Returns a new instance of Bootstrapper.
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ridley/bootstrapper.rb', line 47
def initialize(hosts, options = {})
@hosts = Array(hosts).flatten.collect(&:to_s).uniq
@options = options.dup
@options[:ssh] ||= Hash.new
@options[:ssh] = {
timeout: 5.0,
sudo: true
}.merge(@options[:ssh])
@options[:sudo] = @options[:ssh][:sudo]
end
|
Instance Attribute Details
#hosts ⇒ Array<String>
11
12
13
|
# File 'lib/ridley/bootstrapper.rb', line 11
def hosts
@hosts
end
|
#options ⇒ Hash
14
15
16
|
# File 'lib/ridley/bootstrapper.rb', line 14
def options
@options
end
|
Instance Method Details
62
63
64
|
# File 'lib/ridley/bootstrapper.rb', line 62
def contexts
@contexts ||= @hosts.collect { |host| Context.create(host, options) }
end
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/ridley/bootstrapper.rb', line 69
def run
workers = Array.new
futures = contexts.collect do |context|
log.info { "Running bootstrap command on #{context.host}" }
workers << worker = context.host_connector::Worker.new(context.host, self.options.freeze)
worker.future.run(context.template_binding.boot_command)
end
HostConnector::ResponseSet.new.tap do |response_set|
futures.each do |future|
status, response = future.value
response_set.add_response(response)
end
end
ensure
workers.map(&:terminate)
end
|