Class: KnifeSpork::SporkNodeRunListAdd

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/spork-node-runlistadd.rb

Instance Method Summary collapse

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chef/knife/spork-node-runlistadd.rb', line 18

def run
  self.class.send(:include, KnifeSpork::Runner)
  self.config = Chef::Config.merge!(config)

  if @name_args.empty?
    show_usage
    ui.error("You must specify a node name and item to add")
    exit 1
  end

  @object_name = @name_args.first

  @object_secondary_name = @name_args[1..-1].map do |entry|
    entry.split(',').map { |e| e.strip }
  end.flatten.to_s

  run_plugins(:before_noderunlistadd)
  pre_node = load_node(@object_name)
  node_runlistadd
  post_node = load_node(@object_name)
  @object_difference = json_diff(pre_node,post_node).to_s
  run_plugins(:after_noderunlistadd)
end