class Spaux::CLI
Public Instance Methods
converge()
click to toggle source
# 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)
click to toggle source
# 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
savekey()
click to toggle source
# 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)
click to toggle source
# File lib/spaux/cli.rb, line 51 def ssh(nodename) ssh_cmd = Spaux::CLI::SSHSubcommand.new ssh_cmd.run(nodename, options) end
Private Instance Methods
get_work_dir(options)
click to toggle source
# File lib/spaux/cli.rb, line 57 def get_work_dir(options) dir = options[:dir] current = options[:current] if !dir work_dir = if ENV['SPAUX_HOME'] ENV['SPAUX_HOME'] elsif current ::File.join(ENV['PWD'], 'current') else Dir.mktmpdir end else work_dir = dir end end
parse_config_file(file)
click to toggle source
# File lib/spaux/cli.rb, line 72 def parse_config_file(file) begin eval(IO.read(file)) rescue Errno::ENOENT => e puts e.message {} end end