Class: Chef::Knife::NodeRunListSet
- Inherits:
-
Knife
- Object
- Knife
- Chef::Knife::NodeRunListSet
- Defined in:
- lib/chef/knife/node_run_list_set.rb
Instance Method Summary collapse
- #run ⇒ Object
-
#set_run_list(node, entries) ⇒ Object
Clears out any existing run_list_items and sets them to the specified entries.
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef/knife/node_run_list_set.rb', line 32 def run if @name_args.size < 2 ui.fatal "You must supply both a node name and a run list." show_usage exit 1 elsif @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[1..].map do |entry| entry.split(",").map(&:strip) end.flatten else # Convert to array and remove the extra spaces entries = @name_args[1].split(",").map(&:strip) end node = Chef::Node.load(@name_args[0]) set_run_list(node, entries) node.save config[:run_list] = true output(format_for_display(node)) end |
#set_run_list(node, entries) ⇒ Object
Clears out any existing run_list_items and sets them to the specified entries
59 60 61 62 |
# File 'lib/chef/knife/node_run_list_set.rb', line 59 def set_run_list(node, entries) node.run_list.run_list_items.clear entries.each { |e| node.run_list << e } end |