Merge pull request #17 from alram/wip-rpm-distro
Chef support for CentOS/RHEL, Fedora and SuSE Reviewed-by-not-tested-by: Sage Weil <sage@inktank.com>
This commit is contained in:
commit
64842981ac
@ -1,3 +1,4 @@
|
|||||||
default['ceph']['branch'] = "stable" # Can be stable, testing or dev.
|
default['ceph']['branch'] = "stable" # Can be stable, testing or dev.
|
||||||
# Major release version to install or gitbuilder branch
|
# Major release version to install or gitbuilder branch
|
||||||
default['ceph']['version'] = "bobtail"
|
default['ceph']['version'] = "bobtail"
|
||||||
|
default['ceph']['el_add_epel'] = true
|
@ -118,3 +118,12 @@ def have_quorum?()
|
|||||||
state = JSON.parse(mon_status)['state']
|
state = JSON.parse(mon_status)['state']
|
||||||
return QUORUM_STATES.include?(state)
|
return QUORUM_STATES.include?(state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def service_type()
|
||||||
|
case node['platform']
|
||||||
|
when 'ubuntu'
|
||||||
|
return "upstart"
|
||||||
|
else
|
||||||
|
return "sysvinit"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -4,7 +4,7 @@ case node['ceph']['branch']
|
|||||||
when "stable"
|
when "stable"
|
||||||
apt_repository "ceph-stable" do
|
apt_repository "ceph-stable" do
|
||||||
repo_name "ceph"
|
repo_name "ceph"
|
||||||
uri "http://www.ceph.com/debian-#{node['ceph']['version']}/"
|
uri "http://ceph.com/debian-#{node['ceph']['version']}/"
|
||||||
distribution node['lsb']['codename']
|
distribution node['lsb']['codename']
|
||||||
components ["main"]
|
components ["main"]
|
||||||
key "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc"
|
key "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc"
|
||||||
@ -26,3 +26,4 @@ when "dev"
|
|||||||
key "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
|
key "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
packages = []
|
||||||
|
|
||||||
|
case node['platform_family']
|
||||||
|
when "debian"
|
||||||
packages = %w{
|
packages = %w{
|
||||||
ceph
|
ceph
|
||||||
ceph-common
|
ceph-common
|
||||||
@ -29,6 +33,18 @@ if node['ceph']['install_debug']
|
|||||||
}
|
}
|
||||||
packages += packages_dbg
|
packages += packages_dbg
|
||||||
end
|
end
|
||||||
|
when "rhel", "fedora"
|
||||||
|
packages = %w{
|
||||||
|
ceph
|
||||||
|
}
|
||||||
|
|
||||||
|
if node['ceph']['install_debug']
|
||||||
|
packages_dbg = %w{
|
||||||
|
ceph-debug
|
||||||
|
}
|
||||||
|
packages += packages_dbg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
packages.each do |pkg|
|
packages.each do |pkg|
|
||||||
package pkg do
|
package pkg do
|
||||||
|
@ -19,10 +19,20 @@ require 'json'
|
|||||||
include_recipe "ceph::default"
|
include_recipe "ceph::default"
|
||||||
include_recipe "ceph::conf"
|
include_recipe "ceph::conf"
|
||||||
|
|
||||||
service "ceph-mon-all-starter" do
|
service_type = service_type()
|
||||||
|
service "ceph_mon" do
|
||||||
|
case service_type
|
||||||
|
when "upstart"
|
||||||
|
service_name "ceph-mon-all-starter"
|
||||||
provider Chef::Provider::Service::Upstart
|
provider Chef::Provider::Service::Upstart
|
||||||
action [:enable]
|
action :enable
|
||||||
|
when "sysvinit"
|
||||||
|
service_name "ceph"
|
||||||
|
provider Chef::Provider::Service::Init
|
||||||
end
|
end
|
||||||
|
supports :restart => true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# TODO cluster name
|
# TODO cluster name
|
||||||
cluster = 'ceph'
|
cluster = 'ceph'
|
||||||
@ -31,6 +41,7 @@ execute 'ceph-mon mkfs' do
|
|||||||
command <<-EOH
|
command <<-EOH
|
||||||
set -e
|
set -e
|
||||||
mkdir -p /var/run/ceph
|
mkdir -p /var/run/ceph
|
||||||
|
mkdir -p /var/lib/ceph/mon/ceph-#{node['hostname']}
|
||||||
# TODO chef creates doesn't seem to suppressing re-runs, do it manually
|
# TODO chef creates doesn't seem to suppressing re-runs, do it manually
|
||||||
if [ -e '/var/lib/ceph/mon/ceph-#{node["hostname"]}/done' ]; then
|
if [ -e '/var/lib/ceph/mon/ceph-#{node["hostname"]}/done' ]; then
|
||||||
echo 'ceph-mon mkfs already done, skipping'
|
echo 'ceph-mon mkfs already done, skipping'
|
||||||
@ -43,11 +54,11 @@ ceph-authtool "$KR" --create-keyring --name=mon. --add-key='#{node["ceph"]["moni
|
|||||||
ceph-mon --mkfs -i #{node['hostname']} --keyring "$KR"
|
ceph-mon --mkfs -i #{node['hostname']} --keyring "$KR"
|
||||||
rm -f -- "$KR"
|
rm -f -- "$KR"
|
||||||
touch /var/lib/ceph/mon/ceph-#{node['hostname']}/done
|
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
|
EOH
|
||||||
creates '/var/lib/ceph/mon/ceph-#{node["hostname"]}/done'
|
creates '/var/lib/ceph/mon/ceph-#{node["hostname"]}/done'
|
||||||
creates '/var/lib/ceph/mon/ceph-#{node["hostname"]}/upstart'
|
creates "/var/lib/ceph/mon/ceph-#{node["hostname"]}/#{service_type}"
|
||||||
notifies :start, "service[ceph-mon-all-starter]", :immediately
|
notifies :start, "service[ceph_mon]", :immediately
|
||||||
end
|
end
|
||||||
|
|
||||||
ruby_block "tell ceph-mon about its peers" do
|
ruby_block "tell ceph-mon about its peers" do
|
||||||
|
@ -44,12 +44,19 @@ if !search(:node,"hostname:#{node['hostname']} AND dmcrypt:true").empty?
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
service "ceph-osd-all" do
|
service_type = service_type()
|
||||||
provider Chef::Provider::Service::Upstart
|
service "ceph_osd" do
|
||||||
|
case service_type
|
||||||
|
when "sysvinit"
|
||||||
|
service_name "ceph"
|
||||||
|
provider Chef::Provider::Service::Init
|
||||||
|
when "upstart"
|
||||||
service_name "ceph-osd-all"
|
service_name "ceph-osd-all"
|
||||||
supports :restart => true
|
provider Chef::Provider::Service::Upstart
|
||||||
action :enable
|
action :enable
|
||||||
end
|
end
|
||||||
|
supports :restart => true
|
||||||
|
end
|
||||||
|
|
||||||
mons = get_mon_nodes("ceph_bootstrap_osd_key:*")
|
mons = get_mon_nodes("ceph_bootstrap_osd_key:*")
|
||||||
|
|
||||||
@ -130,7 +137,7 @@ else
|
|||||||
execute "Creating Ceph OSD on #{osd_device['device']}" do
|
execute "Creating Ceph OSD on #{osd_device['device']}" do
|
||||||
command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']}"
|
command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']}"
|
||||||
action :run
|
action :run
|
||||||
notifies :start, "service[ceph-osd-all]", :immediately
|
notifies :start, "service[ceph_osd]", :immediately
|
||||||
end
|
end
|
||||||
# we add this status to the node env
|
# we add this status to the node env
|
||||||
# so that we can implement recreate
|
# so that we can implement recreate
|
||||||
|
8
recipes/repo.rb
Normal file
8
recipes/repo.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
case node['platform_family']
|
||||||
|
when "debian"
|
||||||
|
include_recipe "ceph::apt"
|
||||||
|
when "rhel", "suse"
|
||||||
|
include_recipe "ceph::rpm"
|
||||||
|
else
|
||||||
|
raise "not supported"
|
||||||
|
end
|
47
recipes/rpm.rb
Normal file
47
recipes/rpm.rb
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
case node['platform_family']
|
||||||
|
when "rhel"
|
||||||
|
version = %x[ cat /etc/redhat-release | awk '{print $3}' | awk -F. '{print $1}' ].chomp
|
||||||
|
release = "el" + version
|
||||||
|
if node['ceph']['el_add_epel'] == true
|
||||||
|
# We need to do this since the EPEL
|
||||||
|
# version might change
|
||||||
|
epel_package = %x[ curl -s http://dl.fedoraproject.org/pub/epel/fullfilelist | grep ^#{version}/#{node['kernel']['machine']}/epel-release ].chomp
|
||||||
|
system "rpm -U http://dl.fedoraproject.org/pub/epel/#{epel_package}"
|
||||||
|
end
|
||||||
|
when "fedora"
|
||||||
|
version = %x[ cat /etc/fedora-release | awk '{print $3}' ].chomp
|
||||||
|
release = "fc" + version
|
||||||
|
when "suse"
|
||||||
|
suse = %x[ head -n1 /etc/SuSE-release| awk '{print $1}' ].chomp.downcase #can be suse or opensuse
|
||||||
|
version = %x[ grep VERSION /etc/SuSE-release | awk -F'= ' '{print $2}' ].chomp
|
||||||
|
release = suse + version
|
||||||
|
end
|
||||||
|
|
||||||
|
end_path = "/#{release}/x86_64/ceph-release-1-0.#{release}.noarch.rpm"
|
||||||
|
case node['ceph']['branch']
|
||||||
|
when "stable"
|
||||||
|
path = "http://ceph.com/rpm-#{node['ceph']['version']}" + end_path
|
||||||
|
system "rpm -U #{path}"
|
||||||
|
when "testing"
|
||||||
|
path = "http://ceph.com/rpm-testing" + end_path
|
||||||
|
system "rpm -U #{path}"
|
||||||
|
when "dev"
|
||||||
|
if node['platform'] == "centos"
|
||||||
|
baseurl="http://gitbuilder.ceph.com/ceph-rpm-centos#{version}-x86_64-basic/ref/#{node['ceph']['version']}/x86_64/"
|
||||||
|
elsif node['platform'] == "fedora"
|
||||||
|
baseurl="http://gitbuilder.ceph.com/ceph-rpm-#{release}-x86_64-basic/ref/#{node['ceph']['version']}/RPMS/x86_64/"
|
||||||
|
else
|
||||||
|
raise "repository not available for your distribution"
|
||||||
|
end
|
||||||
|
# Instead of using the yum cookbook,
|
||||||
|
# we do it this way. It avoids a dependency
|
||||||
|
system "curl -s 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc' > /etc/pki/rpm-gpg/RPM-GPG-KEY-CEPH"
|
||||||
|
system "cat > /etc/yum.repos.d/ceph.repo << EOF\n" \
|
||||||
|
"[ceph]\n" \
|
||||||
|
"name=Ceph\n" \
|
||||||
|
"baseurl=#{baseurl}\n" \
|
||||||
|
"enabled=1\n" \
|
||||||
|
"gpgcheck=1\n" \
|
||||||
|
"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CEPH\n" \
|
||||||
|
"EOF\n"
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user