Class: Chef::Knife::UpdateRecipes

Inherits:
Chef::Knife show all
Includes:
Update
Defined in:
lib/chef/knife/update_recipes.rb

Instance Method Summary collapse

Methods included from Update

#except, included, #node_list, #only, #recipes, #target_version

Instance Method Details

#runObject



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/update_recipes.rb', line 28

def run
  list  = node_list
  compatible = recipes(only(list, target_version))
  unknown = recipes(except(list, target_version))
  compatible.each { |recipe, _| unknown.delete(recipe.to_s) }

  if compatible.any?
    ui.msg "recipes already used on Chef #{target_version}:"
    compatible.sort_by { |k, _| k }.each do |item, _|
      ui.msg "  #{item}"
    end
    ui.msg ''
  end

  if unknown.any?
    ui.msg "recipes not used on Chef #{target_version}:"
    unknown.sort_by { |k, _| k }.each do |item, nodes|
      ui.msg "  #{item} (used on #{nodes} nodes)"
    end
    ui.msg ''
  end
end