Module: Chef::Knife::DSL::Support

Defined in:
lib/knife/dsl.rb

Class Method Summary collapse

Class Method Details

.run_knife(command, args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/knife/dsl.rb', line 7

def self.run_knife(command, args)
  unless command.kind_of?(Array)
    command = command.to_s.split(/[\s_]+/)
  end

  command += args

  if ENV["CHEF_CONFIG"]
    command += ['-c', ENV["CHEF_CONFIG"]]
  end

  opts = Chef::Application::Knife.new.options
  Chef::Knife.run(command, opts)
  return 0
rescue SystemExit => e
  return e.status
end