Class: BuckKnife::ProjectCreate

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/project_create.rb

Instance Method Summary collapse

Instance Method Details

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/knife/project_create.rb', line 27

def run
  project   = project_from_arg_or_ask
  node_name = @name_args[1]
  nodes     = Array(project.node(node_name) || project.nodes)

  project.identity_file = config[:identity_file] if config[:identity_file]
  project.provider      = config[:provider] if config[:provider]
  project.ssh_username  = config[:ssh_username] if config[:ssh_username]

  unless project.valid?
    ui.fatal("The #{project.name}.json file has some errors that need to be fixed:")
    project.errors.each do |att, err|
      ui.fatal("'#{att}' #{err}")
    end

    exit 1
  end

  nodes.each do |node|
    ui.output "# Run this command to create #{node.name}:"
    ui.output BuckKnife::Commands::Create[project.provider].new(project, node)
  end
end