Skip to content

Instantly share code, notes, and snippets.

@stefhen
Last active October 21, 2015 21:20
Show Gist options
  • Select an option

  • Save stefhen/cedd43a701f25e9539d5 to your computer and use it in GitHub Desktop.

Select an option

Save stefhen/cedd43a701f25e9539d5 to your computer and use it in GitHub Desktop.
machine_tag search example
include_recipe "machine_tag::default"
# Tag host with seed status
machine_tag "cassandra:seed_host=#{node[:cassandra][:is_seed_host]}" do
action :create
end
# Tag host with broadcast and listen addresses for discovery
machine_tag "cassandra:broadcast_address=#{node[:cassandra][:broadcast_address]}" do
action :create
end
machine_tag "cassandra:listen_address=#{node[:cassandra][:listen_address]}" do
action :create
end
class Chef::Recipe
include Chef::MachineTagHelper
end
include_recipe 'machine_tag::default'
Chef::Log.info 'Beginning gluster search'
glusterfs_peers = []
tags_results = tag_search(node, 'gluster:server=true')
Chef::Log.info 'tags:' + tags_results.inspect
tags_results.each do |itemlist|
ip_address = itemlist['server:private_ip_0'].first.split('=').last
Chef::Log.info ' Here are the ips addresses that we got from ruby block of gluster peer: #{ip_address}'
glusterfs_peers << ip_address
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment