Skip to content

Instantly share code, notes, and snippets.

@stefhen
Created March 6, 2014 20:13
Show Gist options
  • Save stefhen/9398492 to your computer and use it in GitHub Desktop.
Save stefhen/9398492 to your computer and use it in GitHub Desktop.
RightScale tag searching examples
# Obtain information about Jenkins master by querying for its tags
r = rightscale_server_collection "master_server" do
tags "jenkins:master=true"
mandatory_tags "jenkins:active=true"
action :nothing
end
r.run_action(:load)
master_ip = ""
master_port = ""
r = ruby_block "find master" do
block do
node[:server_collection]["master_server"].each do |id, tags|
master_ip_tag = tags.detect { |u| u =~ /jenkins:listen_ip/ }
master_port_tag = tags.detect { |u| u =~ /jenkins:listen_port/ }
master_ip = master_ip_tag.split(/=/, 2).last.chomp
master_port = master_port_tag.split(/=/, 2).last.chomp
Chef::Log.info "Master IP: #{master_ip}"
Chef::Log.info "Master Port: #{master_port}"
end
end
end
r.run_action(:create)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment