]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cookbooks.git/commitdiff
Upstart and SYSV Init support
authorAlexandre Marangone <alexandre.marangone@inktank.com>
Thu, 21 Mar 2013 18:02:32 +0000 (11:02 -0700)
committerAlexandre Marangone <alexandre.marangone@inktank.com>
Tue, 26 Mar 2013 21:56:24 +0000 (14:56 -0700)
- 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>
libraries/default.rb
recipes/mon.rb
recipes/osd.rb

index 687e3d7e077212a2e626d7a8dc5d64f88082a771..308d883fd5d7eff6e10f4b282f4b0d454ae0e5ef 100644 (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
index 4b96429c8ba24872442431e0c92e9a67af570821..f523d0e5fe9a28b857496714569604dec8620642 100644 (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
index c79a229a0443a82a0cd6b3c9588870326b8a3bf2..ce26224a70b98d4c90bae8607fdc2fcf4b1a56e1 100644 (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