Parent

Files

Class/Module Index [+]

Quicksearch

Chef::Knife::NodeRunListAdd

Public Instance Methods

add_to_run_list(node, entries, after=nil) click to toggle source
# File lib/chef/knife/node_run_list_add.rb, line 58
def add_to_run_list(node, entries, after=nil)
  if after
    nlist = []
    node.run_list.each do |entry|
      nlist << entry
      if entry == after
        entries.each { |e| nlist << e }
      end
    end
    node.run_list.reset!(nlist)
  else
    entries.each { |e| node.run_list << e }
  end
end
run() click to toggle source
# File lib/chef/knife/node_run_list_add.rb, line 37
def run
  node = Chef::Node.load(@name_args[0])
  if @name_args.size > 2
    # Check for nested lists and create a single plain one
    entries = @name_args[1..-1].map do |entry|
      entry.split(',').map { |e| e.strip }
    end.flatten
  else
    # Convert to array and remove the extra spaces
    entries = @name_args[1].split(',').map { |e| e.strip }
  end

  add_to_run_list(node, entries, config[:after])

  node.save

  config[:run_list] = true

  output(format_for_display(node))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.