From a27adb38bbd0fc6e78d66698c0ccffb8eb69152e Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Fri, 18 Sep 2015 15:55:56 +0200 Subject: [PATCH] Remove crowbar stuff --- libraries/default.rb | 38 ++++--------- recipes/osd.rb | 128 ++++++++++++++++++------------------------- 2 files changed, 64 insertions(+), 102 deletions(-) diff --git a/libraries/default.rb b/libraries/default.rb index 297da37..691f574 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -1,26 +1,14 @@ require 'json' -def crowbar? - !defined?(Chef::Recipe::Barclamp).nil? -end - def mon_env_search_string - if crowbar? - mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]') - unless mon_roles.empty? - search_string = mon_roles.map { |role_object| 'roles:' + role_object.name }.join(' OR ') - search_string = "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}" - end - else - 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}" - # search for any mon nodes - end + 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}" + # search for any mon nodes end search_string end @@ -110,14 +98,10 @@ def mon_addresses mons << node if node['ceph']['is_mon'] mons += mon_nodes - if crowbar? - mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, 'admin').address } + if node['ceph']['config']['global'] && node['ceph']['config']['global']['public network'] + mon_ips = mons.map { |nodeish| find_node_ip_in_network(node['ceph']['config']['global']['public network'], nodeish) } else - if node['ceph']['config']['global'] && node['ceph']['config']['global']['public network'] - mon_ips = mons.map { |nodeish| find_node_ip_in_network(node['ceph']['config']['global']['public network'], nodeish) } - else - mon_ips = mons.map { |node| node['ipaddress'] + ':6789' } - end + mon_ips = mons.map { |node| node['ipaddress'] + ':6789' } end end mon_ips.reject(&:nil?).uniq diff --git a/recipes/osd.rb b/recipes/osd.rb index d07f161..69d3daf 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -61,90 +61,68 @@ sensitive true if Chef::Resource::Execute.method_defined? :sensitive end -if crowbar? - node['crowbar']['disks'].each do |disk, _data| - execute "ceph-disk-prepare #{disk}" do - command "ceph-disk-prepare /dev/#{disk}" - only_if { node['crowbar']['disks'][disk]['usage'] == 'Storage' } - notifies :run, 'execute[udev trigger]', :immediately +# Calling ceph-disk-prepare is sufficient for deploying an OSD +# After ceph-disk-prepare finishes, the new device will be caught +# by udev which will run ceph-disk-activate on it (udev will map +# the devices if dm-crypt is used). +# IMPORTANT: +# - Always use the default path for OSD (i.e. /var/lib/ceph/ +# osd/$cluster-$id) +# - $cluster should always be ceph +# - The --dmcrypt option will be available starting w/ Cuttlefish +if node['ceph']['osd_devices'] + devices = node['ceph']['osd_devices'] + + devices = Hash[(0...devices.size).zip devices] unless devices.is_a? Hash + + devices.each do |index, osd_device| + unless osd_device['status'].nil? + Log.info("osd: osd_device #{osd_device} has already been setup.") + next end - ruby_block "set disk usage for #{disk}" do - block do - node.set['crowbar']['disks'][disk]['usage'] = 'ceph-osd' - node.save - end + directory osd_device['device'] do # ~FC022 + owner 'root' + group 'root' + recursive true + only_if { osd_device['type'] == 'directory' } end - end - - execute 'udev trigger' do - command 'udevadm trigger --subsystem-match=block --action=add' - action :nothing - end -else - # Calling ceph-disk-prepare is sufficient for deploying an OSD - # After ceph-disk-prepare finishes, the new device will be caught - # by udev which will run ceph-disk-activate on it (udev will map - # the devices if dm-crypt is used). - # IMPORTANT: - # - Always use the default path for OSD (i.e. /var/lib/ceph/ - # osd/$cluster-$id) - # - $cluster should always be ceph - # - The --dmcrypt option will be available starting w/ Cuttlefish - if node['ceph']['osd_devices'] - devices = node['ceph']['osd_devices'] - - devices = Hash[(0...devices.size).zip devices] unless devices.is_a? Hash - - devices.each do |index, osd_device| - unless osd_device['status'].nil? - Log.info("osd: osd_device #{osd_device} has already been setup.") - next - end - - directory osd_device['device'] do # ~FC022 - owner 'root' - group 'root' - recursive true - only_if { osd_device['type'] == 'directory' } - end - dmcrypt = osd_device['encrypted'] == true ? '--dmcrypt' : '' + dmcrypt = osd_device['encrypted'] == true ? '--dmcrypt' : '' - execute "ceph-disk-prepare on #{osd_device['device']}" do - command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']} #{osd_device['journal']}" - action :run - notifies :create, "ruby_block[save osd_device status #{index}]", :immediately - end + execute "ceph-disk-prepare on #{osd_device['device']}" do + command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']} #{osd_device['journal']}" + action :run + notifies :create, "ruby_block[save osd_device status #{index}]", :immediately + end - execute "ceph-disk-activate #{osd_device['device']}" do - only_if { osd_device['type'] == 'directory' } - end + execute "ceph-disk-activate #{osd_device['device']}" do + only_if { osd_device['type'] == 'directory' } + end - # we add this status to the node env - # so that we can implement recreate - # and/or delete functionalities in the - # future. - ruby_block "save osd_device status #{index}" do - block do - node.normal['ceph']['osd_devices'][index]['status'] = 'deployed' - node.save - end - action :nothing + # we add this status to the node env + # so that we can implement recreate + # and/or delete functionalities in the + # future. + ruby_block "save osd_device status #{index}" do + block do + node.normal['ceph']['osd_devices'][index]['status'] = 'deployed' + node.save end + action :nothing end - service 'ceph_osd' do - case service_type - when 'upstart' - service_name 'ceph-osd-all-starter' - provider Chef::Provider::Service::Upstart - else - service_name 'ceph' - end - action [:enable, :start] - supports :restart => true + end + service 'ceph_osd' do + case service_type + when 'upstart' + service_name 'ceph-osd-all-starter' + provider Chef::Provider::Service::Upstart + else + service_name 'ceph' end - else - Log.info('node["ceph"]["osd_devices"] empty') + action [:enable, :start] + supports :restart => true end +else + Log.info('node["ceph"]["osd_devices"] empty') end