lib/ridley/bootstrapper.rb in ridley-0.10.0.rc1 vs lib/ridley/bootstrapper.rb in ridley-0.10.0.rc2

- old
+ new

@@ -2,18 +2,15 @@ # @author Jamie Winsor <reset@riotgames.com> class Bootstrapper autoload :Context, 'ridley/bootstrapper/context' include Celluloid - include Celluloid::Logger - + include Ridley::Logging + # @return [Array<String>] attr_reader :hosts - # @return [Array<Bootstrapper::Context>] - attr_reader :contexts - # @return [Hash] attr_reader :options # @param [Array<#to_s>] hosts # @option options [Hash] :ssh @@ -45,28 +42,34 @@ # @option options [Boolean] :sudo (true) # bootstrap with sudo (default: true) # @option options [String] :template # bootstrap template to use def initialize(hosts, options = {}) - @hosts = Array(hosts).collect(&:to_s).uniq + @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] - @contexts = @hosts.collect do |host| - Context.create(host, options) - end end + # @raise [Errors::HostConnectionError] if a node is unreachable + # + # @return [Array<Bootstrapper::Context>] + def contexts + @contexts ||= @hosts.collect { |host| Context.create(host, options) } + end + + # @raise [Errors::HostConnectionError] if a node is unreachable + # # @return [HostConnector::ResponseSet] def run workers = Array.new futures = contexts.collect do |context| - info "Running bootstrap command on #{context.host}" + 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