Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created October 17, 2008 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamhjk/17325 to your computer and use it in GitHub Desktop.
Save adamhjk/17325 to your computer and use it in GitHub Desktop.
task :classify_nodes do
@dns_names.each do |description|
description =~ /^(.+?)\..+$/
hostname = $1
node = @ic.get_node(hostname)
if exists?(:puppet_env)
EC2_DATA[:iclassify_attribs][:puppet_env] = puppet_env
end
node.tags = EC2_DATA[:iclassify_tags]
EC2_DATA[:iclassify_attribs].each do |name, values|
exists = node.attribs.detect { |a| a[:name] == name }
if exists
exists[:values] = values.kind_of?(Array) ? values : [ values ]
else
node.attribs << { :name => name, :values => values.kind_of?(Array) ? values : [ values ] }
end
end
logger.info("Classifying #{node.attrib?('fqdn')} as #{EC2_DATA[:iclassify_tags].join(', ')}")
puts node.inspect
@ic.update_node(node)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment