From: Walter Huf Date: Tue, 8 Jul 2014 20:16:44 +0000 (-0500) Subject: Allows nodes to specify a ceph environment to search X-Git-Tag: v0.8.0~29^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F112%2Fhead;p=ceph-cookbooks.git Allows nodes to specify a ceph environment to search If a server is in a different environment than the ceph mons, but it still wants to connect to the ceph cluster, it can specify a node['ceph']['search_environment'] attribute that matches the ceph mons' node.chef_environment attribute. This will enable the server to find the ceph mon nodes, register for cephx keyrings, and create a working ceph.conf file --- diff --git a/attributes/conf.rb b/attributes/conf.rb index a2045c6..8836945 100644 --- a/attributes/conf.rb +++ b/attributes/conf.rb @@ -1,2 +1,3 @@ default['ceph']['config'] = {} default['ceph']['config-sections'] = {} +default['ceph']['search_environment'] = true diff --git a/libraries/default.rb b/libraries/default.rb index b7b34dc..eb165d4 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -5,7 +5,7 @@ def crowbar? !defined?(Chef::Recipe::Barclamp).nil? end -def mon_nodes +def mon_env_search_string if crowbar? mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]') unless mon_roles.empty? @@ -13,8 +13,22 @@ def mon_nodes search_string = "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}" end else - search_string = "ceph_is_mon:true AND chef_environment:#{node.chef_environment}" + search_string = 'ceph_is_mon:true' + if node['ceph']['search_environment'].is_a?(String) + # search for nodes with this particular env + search_string += " AND chef_environment:#{node['ceph']['search_environment']}" + elsif node['ceph']['search_environment'] + # search for any nodes with this environment + search_string += " AND chef_environment:#{node.chef_environment}" + else + # search for any mon nodes + end end + search_string +end + +def mon_nodes + search_string = mon_env_search_string if use_cephx? && !node['ceph']['encrypted_data_bags'] search_string = "(#{search_string}) AND (ceph_bootstrap_osd_key:*)" diff --git a/templates/default/ceph.conf.erb b/templates/default/ceph.conf.erb index e82d191..6d6e4d2 100644 --- a/templates/default/ceph.conf.erb +++ b/templates/default/ceph.conf.erb @@ -1,6 +1,8 @@ [global] +<% if node['ceph']['is_mon'] -%> fsid = <%= node["ceph"]["config"]["fsid"] %> mon initial members = <%= node["ceph"]["config"]["mon_initial_members"] %> +<% end -%> mon host = <%= @mon_addresses.sort.join(', ') %> <% if (! node['ceph']['config']['global'].nil?) -%> <% node['ceph']['config']['global'].sort.each do |k, v| %>