Class: Chef::Knife::TagCreate

Inherits:
Knife
  • Object
show all
Defined in:
lib/chef/knife/tag_create.rb

Instance Method Summary collapse

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/knife/tag_create.rb', line 33

def run
  name = @name_args[0]
  tags = @name_args[1..]

  if name.nil? || tags.nil? || tags.empty?
    show_usage
    ui.fatal("You must specify a node name and at least one tag.")
    exit 1
  end

  node = Chef::Node.load name
  tags.each do |tag|
    (node.tags << tag).uniq!
  end
  node.save
  ui.info("Created tags #{tags.join(", ")} for node #{name}.")
end