Upstart and SYSV Init support

- Handles different service names between upstart
and sysvinit.
- Create mon_dir/(upstart|sysvinit) depending on
service to be used.

Signed-off-by: Alexandre Marangone <alexandre.marangone@inktank.com>
This commit is contained in:
Alexandre Marangone 2013-03-21 11:02:32 -07:00
parent 57c6e08276
commit d1e074afd0
3 changed files with 37 additions and 11 deletions

View File

@ -118,3 +118,12 @@ def have_quorum?()
state = JSON.parse(mon_status)['state']
return QUORUM_STATES.include?(state)
end
def service_type()
case node['platform']
when 'ubuntu'
return "upstart"
else
return "sysvinit"
end
end

View File

@ -19,11 +19,21 @@ require 'json'
include_recipe "ceph::default"
include_recipe "ceph::conf"
service "ceph-mon-all-starter" do
provider Chef::Provider::Service::Upstart
action [:enable]
service_type = service_type()
service "ceph_mon" do
case service_type
when "upstart"
service_name "ceph-mon-all-starter"
provider Chef::Provider::Service::Upstart
action :enable
when "sysvinit"
service_name "ceph"
provider Chef::Provider::Service::Init
end
supports :restart => true
end
# TODO cluster name
cluster = 'ceph'
@ -43,11 +53,11 @@ ceph-authtool "$KR" --create-keyring --name=mon. --add-key='#{node["ceph"]["moni
ceph-mon --mkfs -i #{node['hostname']} --keyring "$KR"
rm -f -- "$KR"
touch /var/lib/ceph/mon/ceph-#{node['hostname']}/done
touch /var/lib/ceph/mon/ceph-#{node['hostname']}/upstart
touch /var/lib/ceph/mon/ceph-#{node['hostname']}/#{service_type}
EOH
creates '/var/lib/ceph/mon/ceph-#{node["hostname"]}/done'
creates '/var/lib/ceph/mon/ceph-#{node["hostname"]}/upstart'
notifies :start, "service[ceph-mon-all-starter]", :immediately
creates "/var/lib/ceph/mon/ceph-#{node["hostname"]}/#{service_type}"
notifies :start, "service[ceph_mon]", :immediately
end
ruby_block "tell ceph-mon about its peers" do

View File

@ -44,11 +44,18 @@ if !search(:node,"hostname:#{node['hostname']} AND dmcrypt:true").empty?
end
end
service "ceph-osd-all" do
provider Chef::Provider::Service::Upstart
service_name "ceph-osd-all"
service_type = service_type()
service "ceph_osd" do
case service_type
when "sysvinit"
service_name "ceph"
provider Chef::Provider::Service::Init
when "upstart"
service_name "ceph-osd-all"
provider Chef::Provider::Service::Upstart
action :enable
end
supports :restart => true
action :enable
end
mons = get_mon_nodes("ceph_bootstrap_osd_key:*")
@ -130,7 +137,7 @@ else
execute "Creating Ceph OSD on #{osd_device['device']}" do
command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']}"
action :run
notifies :start, "service[ceph-osd-all]", :immediately
notifies :start, "service[ceph_osd]", :immediately
end
# we add this status to the node env
# so that we can implement recreate