Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove crowbar specific #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 11 additions & 27 deletions libraries/default.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
128 changes: 53 additions & 75 deletions recipes/osd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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