12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/chef/knife/project_assign.rb', line 12
def run
project = project_from_arg_or_ask
node_name = @name_args[1]
nodes = Array(project.node(node_name) || project.nodes)
nodes.each do |node|
ui.output "# Run this command to assign project attributes to #{node.name}:"
code_block = <<-EOF.gsub("\n", "; ")
node = nodes.search(:name => "#{node.name}").first
node.set[:#{BuckKnife.namespace}][:project] = "#{project.name}"
node.set[:#{BuckKnife.namespace}][:environment] = "#{node.environment}"
node.save
EOF
ui.output BuckKnife::Command.new("knife").arg("exec").opt("-E", code_block )
end
end
|