Class: Spaux::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/spaux/cli.rb,
lib/spaux/cli/ssh_subcommand.rb

Defined Under Namespace

Classes: SSHSubcommand

Instance Method Summary collapse

Instance Method Details

#convergeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/spaux/cli.rb', line 17

def converge
  work_dir = get_work_dir(options)
  FileUtils.mkdir_p work_dir

  begin
    chef_config = parse_config_file(options[:config]) if options[:config]
    spaux_config = parse_config_file(options[:spaux_config]) if options[:spaux_config]
    client = Spaux::Chef::Client.new(work_dir, chef_config, spaux_config)
    client.run
  rescue Errno::ENOENT => e
    ssh_message = 'error: You need to create a ssh keypair'
    STDERR.puts ssh_message if e.message.match(/id_rsa/)
  end
end

#knife(*args) ⇒ Object



45
46
47
48
49
# File 'lib/spaux/cli.rb', line 45

def knife(*args)
  work_dir = get_work_dir(options)
  knife = Spaux::Chef::Knife.new(work_dir, args)
  knife.run
end

#savekeyObject



33
34
35
36
37
38
39
40
# File 'lib/spaux/cli.rb', line 33

def savekey
  key = Spaux::Chef::Key.new.raw_key
  if !options[:file]
    puts key
  else
    ::File.write(options[:file], key)
  end
end

#ssh(nodename) ⇒ Object



51
52
53
54
# File 'lib/spaux/cli.rb', line 51

def ssh(nodename)
  ssh_cmd = Spaux::CLI::SSHSubcommand.new
  ssh_cmd.run(nodename, options)
end