Skip to content

Instantly share code, notes, and snippets.

@behemphi
Created September 16, 2014 14:28
Show Gist options
  • Save behemphi/8959c3ae0fb3cb583394 to your computer and use it in GitHub Desktop.
Save behemphi/8959c3ae0fb3cb583394 to your computer and use it in GitHub Desktop.
# If this is a large instance we need to locate the database host.
if node.chef_environment.include?('large')
nodes = search(:node, "name:#{node.foobar.instance_name}*")
log "nodes found: #{nodes.count()}"
# Looking for the database host
nodes.each do |n|
# If the database host exists, get its servicenet IP, otherwise fail
# the run.
if n.name.index('-db')
node.set['foobar']['db']['host_ip'] = n.cloud.private_ips[0]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment