class Serverkit::Actions::Base
Constants
- DEFAULT_LOG_LEVEL
Public Class Methods
new(hosts: nil, log_level: nil, recipe_path: nil, ssh_options: nil, variables_path: nil)
click to toggle source
@param [String, nil] hosts @param [Fixnum] log_level @param [String] recipe_path @param [Hash, nil] ssh_options For override default ssh options @param [Stirng, nil] variables_path
# File lib/serverkit/actions/base.rb, line 20 def initialize(hosts: nil, log_level: nil, recipe_path: nil, ssh_options: nil, variables_path: nil) @hosts = hosts @log_level = log_level @recipe_path = recipe_path @ssh_options = ssh_options @variables_path = variables_path end
Public Instance Methods
call()
click to toggle source
# File lib/serverkit/actions/base.rb, line 28 def call setup run end
Private Instance Methods
abort_with_errors()
click to toggle source
# File lib/serverkit/actions/base.rb, line 35 def abort_with_errors abort recipe.errors.map { |error| "Error: #{error}" }.join("\n") end
backends()
click to toggle source
@return [Array<Serverkit::Backends::Base>]
# File lib/serverkit/actions/base.rb, line 40 def backends if has_hosts? hosts.map do |host| Backends::SshBackend.new( host: host, log_level: @log_level, ssh_options: @ssh_options, ) end else [Backends::LocalBackend.new(log_level: @log_level)] end end
bundle()
click to toggle source
# File lib/serverkit/actions/base.rb, line 54 def bundle Bundler.require(:default) rescue Bundler::GemfileNotFound end
has_hosts?()
click to toggle source
# File lib/serverkit/actions/base.rb, line 59 def has_hosts? !@hosts.nil? end
hosts()
click to toggle source
@return [Array<String>, nil]
# File lib/serverkit/actions/base.rb, line 64 def hosts if has_hosts? @hosts.split(",") end end
recipe()
click to toggle source
@return [Serverkit::Recipe]
# File lib/serverkit/actions/base.rb, line 76 def recipe @recipe ||= Loaders::RecipeLoader.new(@recipe_path, variables_path: @variables_path).load end
setup()
click to toggle source
# File lib/serverkit/actions/base.rb, line 70 def setup bundle abort_with_errors unless recipe.valid? end