class Chef::Knife::SousInit

Public Instance Methods

copy_template(location) click to toggle source
# File lib/chef/knife/sous_init.rb, line 24
def copy_template(location)
  FileUtils.mkdir_p(location)

  target_file = File.join(location, 'nodes.example.rb' )

  unless File.exists?(target_file)
    FileUtils.cp(node_manifest_example_path, target_file)
    ui.msg "Example nodes.rb copied to #{target_file}"
  else
    ui.error "File already exists: #{target_file}"
  end
end
node_manifest_example_path() click to toggle source
# File lib/chef/knife/sous_init.rb, line 11
def node_manifest_example_path
  File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'nodes.example.rb'))
end
run() click to toggle source
# File lib/chef/knife/sous_init.rb, line 15
def run
  unless name_args.empty?
    target = File.expand_path(name_args.first)
  else
    target = File.expand_path(Dir.pwd, File.join('nodes'))
  end
  copy_template(target)
end