Class: SilverSpurs::KnifeInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/silver_spurs/knife_interface.rb

Constant Summary collapse

BOOTSTRAP_ARGS_MAP =
{
  :identity_file => '-i',
  :ssh_user => '-x',      
  :node_name => '-N',
  :distro => '-d',
  :bootstrap_version => '--bootstrap-version',
  :bootstrap_proxy => '--bootstrap-proxy',
  :gateway => '-G',
  :json_attributes => '-j',
  :ssh_port => '-p',
  :ssh_password => '--ssh-password',
  :run_list => '-r',
  :template => '--template-file'
}

Class Method Summary collapse

Class Method Details

.bootstrap_command(ip, node_name, deployment_user, deployment_key, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/silver_spurs/knife_interface.rb', line 31

def self.bootstrap_command(ip, node_name, deployment_user, deployment_key, options = {})      
  bootstrap_options = {
    :identity_file => deployment_key,
    :ssh_user => deployment_user,
    :node_name => node_name
  }.merge options

  arguments = expand_bootstrap_args bootstrap_options

  command = ['knife', 'bootstrap', '--no-host-key-verify', *arguments, ip].join ' '      
end

.expand_bootstrap_args(arguments) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/silver_spurs/knife_interface.rb', line 22

def self.expand_bootstrap_args(arguments)
  BOOTSTRAP_ARGS_MAP.map do |arg, flag|
    value = arguments[arg]
    next nil if value.nil?

    "#{flag} '#{value}'"
  end.reject {|arg| arg.nil?}              
end

.supported_argumentsObject



18
19
20
# File 'lib/silver_spurs/knife_interface.rb', line 18

def self.supported_arguments
  BOOTSTRAP_ARGS_MAP.map {|k,v| k}
end