42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/chef/knife/node_run_list_add.rb', line 42
def run
node = Chef::Node.load(@name_args[0])
if @name_args.size > 2
entries = @name_args[1..].map do |entry|
entry.split(",").map(&:strip)
end.flatten
else
entries = @name_args[1].split(",").map(&:strip)
end
if config[:after] && config[:before]
ui.fatal("You cannot specify both --before and --after!")
exit 1
end
if config[:after]
add_to_run_list_after(node, entries, config[:after])
elsif config[:before]
add_to_run_list_before(node, entries, config[:before])
else
add_to_run_list_after(node, entries)
end
node.save
config[:run_list] = true
output(format_for_display(node))
end
|