From: Guilhem Lettron Date: Fri, 16 May 2014 15:54:45 +0000 (+0200) Subject: Big refactor on install part X-Git-Tag: v0.8.0~36^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=024c0243430bd87908ba63775bb55dab8e92b8e3;p=ceph-cookbooks.git Big refactor on install part --- diff --git a/attributes/default.rb b/attributes/default.rb index 66dcf0d..e05bec6 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,3 +2,23 @@ default['ceph']['install_debug'] = false default['ceph']['encrypted_data_bags'] = false default['ceph']['install_repo'] = true + +case node['platform'] +when 'ubuntu' + default['ceph']['init_style'] = 'upstart' +else + default['ceph']['init_style'] = 'sysvinit' +end + +case node['platform_family'] +when 'debian' + packages = ['ceph-common'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['packages'] = packages +when 'rhel', 'fedora' + packages = ['ceph'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['packages'] = packages +else + default['ceph']['packages'] = [] +end diff --git a/attributes/mds.rb b/attributes/mds.rb index 8ab64d8..54c21cd 100644 --- a/attributes/mds.rb +++ b/attributes/mds.rb @@ -1,6 +1,12 @@ -case node['platform'] -when 'ubuntu' - default['ceph']['mds']['init_style'] = 'upstart' +include_attribute 'ceph' + +default['ceph']['mds']['init_style'] = node['init_style'] + +case node['platform_family'] +when 'debian' + packages = ['ceph-mds'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['mds']['packages'] = packages else - default['ceph']['mds']['init_style'] = 'sysvinit' + default['ceph']['mds']['packages'] = [] end diff --git a/attributes/mon.rb b/attributes/mon.rb index 6fad683..5d146e6 100644 --- a/attributes/mon.rb +++ b/attributes/mon.rb @@ -1,7 +1,14 @@ -case node['platform'] -when 'ubuntu' - default['ceph']['mon']['init_style'] = 'upstart' +include_attribute 'ceph' + +default['ceph']['mon']['init_style'] = node['ceph']['init_style'] + +default['ceph']['mon']['secret_file'] = '/etc/chef/secrets/ceph_mon' + +case node['platform_family'] +when 'debian', 'rhel', 'fedora' + packages = ['ceph'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['mon']['packages'] = packages else - default['ceph']['mon']['init_style'] = 'sysvinit' + default['ceph']['mon']['packages'] = [] end -default['ceph']['mon']['secret_file'] = '/etc/chef/secrets/ceph_mon' diff --git a/attributes/osd.rb b/attributes/osd.rb index 48f32d2..addbcce 100644 --- a/attributes/osd.rb +++ b/attributes/osd.rb @@ -1,7 +1,14 @@ -case node['platform'] -when 'ubuntu' - default['ceph']['osd']['init_style'] = 'upstart' +include_attribute 'ceph' + +default['ceph']['osd']['init_style'] = node['ceph']['init_style'] + +default['ceph']['osd']['secret_file'] = '/etc/chef/secrets/ceph_osd' + +case node['platform_family'] +when 'debian', 'rhel', 'fedora' + packages = ['ceph'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['osd']['packages'] = packages else - default['ceph']['osd']['init_style'] = 'sysvinit' + default['ceph']['osd']['packages'] = [] end -default['ceph']['osd']['secret_file'] = '/etc/chef/secrets/ceph_osd' diff --git a/attributes/radosgw.rb b/attributes/radosgw.rb index 9fa7517..833f3c6 100644 --- a/attributes/radosgw.rb +++ b/attributes/radosgw.rb @@ -17,15 +17,23 @@ # limitations under the License. # +include_attribute 'ceph' + default['ceph']['radosgw']['api_fqdn'] = 'localhost' default['ceph']['radosgw']['admin_email'] = 'admin@example.com' default['ceph']['radosgw']['rgw_addr'] = '*:80' default['ceph']['radosgw']['rgw_port'] = false default['ceph']['radosgw']['webserver_companion'] = 'apache2' # can be false default['ceph']['radosgw']['use_apache_fork'] = true -case node['platform'] -when 'ubuntu' - default['ceph']['radosgw']['init_style'] = 'upstart' +default['ceph']['radosgw']['init_style'] = node['ceph']['init_style'] + +case node['platform_family'] +when 'debian' + packages = ['radosgw'] + packages += debug_packages(packages) if node['ceph']['install_debug'] + default['ceph']['radosgw']['packages'] = packages +when 'rhel', 'fedora', 'suse' + default['ceph']['radosgw']['packages'] = ['ceph-radosgw'] else - default['ceph']['radosgw']['init_style'] = 'sysvinit' + default['ceph']['radosgw']['packages'] = [] end diff --git a/attributes/radosgw_apache2.rb b/attributes/radosgw_apache2.rb new file mode 100644 index 0000000..047c2a8 --- /dev/null +++ b/attributes/radosgw_apache2.rb @@ -0,0 +1,6 @@ +case node['platform_family'] +when 'debian', 'suse' + default['ceph']['radosgw']['apache2']['packages'] = ['libapache2-mod-fastcgi'] +when 'rhel', 'fedora' + default['ceph']['radosgw']['apache2']['packages'] = ['mod_fastcgi'] +end diff --git a/libraries/utils.rb b/libraries/utils.rb new file mode 100644 index 0000000..257472f --- /dev/null +++ b/libraries/utils.rb @@ -0,0 +1,14 @@ +def debug_packages(packages) + packages.map { |x| x + debug_ext } +end + +def debug_ext + case node['platform_family'] + when 'debian' + '-dbg' + when 'rhel', 'fedora' + '-debug' + else + '' + end +end diff --git a/recipes/_common.rb b/recipes/_common.rb index 37a0da8..8dbebfd 100644 --- a/recipes/_common.rb +++ b/recipes/_common.rb @@ -1,2 +1,6 @@ +include_recipe 'ceph::_common_install' -include_recipe 'ceph::repo' if node['ceph']['install_repo'] +# Tools needed by cookbook +node['ceph']['packages'].each do |pck| + package pck +end diff --git a/recipes/_common_install.rb b/recipes/_common_install.rb new file mode 100644 index 0000000..171a227 --- /dev/null +++ b/recipes/_common_install.rb @@ -0,0 +1 @@ +include_recipe 'ceph::repo' if node['ceph']['install_repo'] diff --git a/recipes/apt.rb b/recipes/apt.rb index f593cad..d101b00 100644 --- a/recipes/apt.rb +++ b/recipes/apt.rb @@ -25,27 +25,3 @@ apt_repository 'ceph-extras' do key node['ceph']['debian']['extras']['repository_key'] only_if { node['ceph']['extras_repo'] } end - -if node['ceph']['is_radosgw'] \ - && node['ceph']['radosgw']['webserver_companion'] == 'apache2' \ - && node['ceph']['radosgw']['use_apache_fork'] == true - case node['lsb']['codename'] - when 'precise', 'oneiric' - apt_repository 'ceph-apache2' do - repo_name 'ceph-apache2' - uri "http://gitbuilder.ceph.com/apache2-deb-#{node['lsb']['codename']}-x86_64-basic/ref/master" - distribution distribution_codename - components ['main'] - key 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc' - end - apt_repository 'ceph-modfastcgi' do - repo_name 'ceph-modfastcgi' - uri "http://gitbuilder.ceph.com/libapache-mod-fastcgi-deb-#{node['lsb']['codename']}-x86_64-basic/ref/master" - distribution distribution_codename - components ['main'] - key 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc' - end - else - Log.info("Ceph's Apache and Apache FastCGI forks not available for this distribution") - end -end diff --git a/recipes/default.rb b/recipes/default.rb deleted file mode 100644 index 7d1eb57..0000000 --- a/recipes/default.rb +++ /dev/null @@ -1,53 +0,0 @@ -# -# Author:: Kyle Bader -# Cookbook Name:: ceph -# Recipe:: default -# -# Copyright 2011, DreamHost Web Hosting -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -packages = [] - -case node['platform_family'] -when 'debian' - packages = %w( - ceph - ceph-common - ) - - if node['ceph']['install_debug'] - packages_dbg = %w( - ceph-dbg - ceph-common-dbg - ) - packages += packages_dbg - 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| - package pkg do - action :install - end -end diff --git a/recipes/install.rb b/recipes/install.rb new file mode 100644 index 0000000..7d1eb57 --- /dev/null +++ b/recipes/install.rb @@ -0,0 +1,53 @@ +# +# Author:: Kyle Bader +# Cookbook Name:: ceph +# Recipe:: default +# +# Copyright 2011, DreamHost Web Hosting +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +packages = [] + +case node['platform_family'] +when 'debian' + packages = %w( + ceph + ceph-common + ) + + if node['ceph']['install_debug'] + packages_dbg = %w( + ceph-dbg + ceph-common-dbg + ) + packages += packages_dbg + 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| + package pkg do + action :install + end +end diff --git a/recipes/mds.rb b/recipes/mds.rb index 93476cf..69ca3a5 100644 --- a/recipes/mds.rb +++ b/recipes/mds.rb @@ -18,7 +18,7 @@ # limitations under the License. include_recipe 'ceph::_common' -include_recipe 'ceph::default' +include_recipe 'ceph::mds_install' include_recipe 'ceph::conf' cluster = 'ceph' diff --git a/recipes/mds_install.rb b/recipes/mds_install.rb new file mode 100644 index 0000000..3ce533a --- /dev/null +++ b/recipes/mds_install.rb @@ -0,0 +1,5 @@ +include_recipe 'ceph::_common_install' + +node['ceph']['mds']['packages'].each do |pck| + package pck +end diff --git a/recipes/mon.rb b/recipes/mon.rb index 31fc96a..76a5d91 100644 --- a/recipes/mon.rb +++ b/recipes/mon.rb @@ -17,7 +17,7 @@ node.default['ceph']['is_mon'] = true include_recipe 'ceph::_common' -include_recipe 'ceph::default' +include_recipe 'ceph::mon_install' include_recipe 'ceph::conf' service_type = node['ceph']['mon']['init_style'] diff --git a/recipes/mon_install.rb b/recipes/mon_install.rb new file mode 100644 index 0000000..557ad4c --- /dev/null +++ b/recipes/mon_install.rb @@ -0,0 +1,5 @@ +include_recipe 'ceph::_common_install' + +node['ceph']['mon']['packages'].each do |pck| + package pck +end diff --git a/recipes/osd.rb b/recipes/osd.rb index 337af2b..fc2f9c6 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -32,7 +32,7 @@ # ] include_recipe 'ceph::_common' -include_recipe 'ceph::default' +include_recipe 'ceph::osd_install' include_recipe 'ceph::conf' package 'gdisk' do diff --git a/recipes/osd_install.rb b/recipes/osd_install.rb new file mode 100644 index 0000000..21991ad --- /dev/null +++ b/recipes/osd_install.rb @@ -0,0 +1,5 @@ +include_recipe 'ceph::_common_install' + +node['ceph']['osd']['packages'].each do |pck| + package pck +end diff --git a/recipes/radosgw.rb b/recipes/radosgw.rb index 4c86cc7..7fb5903 100644 --- a/recipes/radosgw.rb +++ b/recipes/radosgw.rb @@ -19,30 +19,8 @@ node.default['ceph']['is_radosgw'] = true -case node['platform_family'] -when 'debian' - packages = %w( - radosgw - ) - - if node['ceph']['install_debug'] - packages_dbg = %w( - radosgw-dbg - ) - packages += packages_dbg - end -when 'rhel', 'fedora', 'suse' - packages = %w( - ceph-radosgw - ) -end - -packages.each do |pkg| - package pkg do - action :upgrade - end -end - +include_recipe 'ceph::_common' +include_recipe 'ceph::radosgw_install' include_recipe 'ceph::conf' if !::File.exist?("/var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']}/done") diff --git a/recipes/radosgw_apache2.rb b/recipes/radosgw_apache2.rb index 5402a1d..9f23e51 100644 --- a/recipes/radosgw_apache2.rb +++ b/recipes/radosgw_apache2.rb @@ -17,47 +17,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -case node['platform_family'] -when 'debian', 'suse' - packages = %w( - apache2 - libapache2-mod-fastcgi - ) -when 'rhel', 'fedora' - packages = %w( - httpd - mod_fastcgi - ) -end - -packages.each do |pkg| - package pkg do - action :upgrade - end -end - # For EL, delete the current fastcgi configuration # and set the correct owners for dirs and logs -d_owner = d_group = 'root' -if node['platform_family'] == 'rhel' - file "#{node['apache']['dir']}/conf.d/fastcgi.conf" do - action :delete - backup false - end - d_owner = d_group = 'apache' -end +# d_owner = d_group = 'root' +# if node['platform_family'] == 'rhel' +# file "#{node['apache']['dir']}/conf.d/fastcgi.conf" do +# action :delete +# backup false +# end +# d_owner = d_group = 'apache' +# end + +# %W(/var/run/ceph +# /var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']} +# /var/lib/apache2/ +# ).each do |dir| +# directory dir do +# owner d_owner +# group d_group +# mode '0755' +# recursive true +# action :create +# end +# end + +include_recipe 'ceph::_common' +include_recipe 'ceph::_common_install' +include_recipe 'ceph::radosgw_apache2_repo' -%W(/var/run/ceph - /var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']} - /var/lib/apache2/ -).each do |dir| - directory dir do - owner d_owner - group d_group - mode '0755' - recursive true - action :create - end +node['ceph']['radosgw']['apache2']['packages'].each do |pck| + package pck end include_recipe 'apache2' diff --git a/recipes/radosgw_apache2_repo.rb b/recipes/radosgw_apache2_repo.rb new file mode 100644 index 0000000..df5cf3f --- /dev/null +++ b/recipes/radosgw_apache2_repo.rb @@ -0,0 +1,22 @@ +if node['ceph']['radosgw']['use_apache_fork'] == true + case node['lsb']['codename'] + when 'precise', 'oneiric' + apt_repository 'ceph-apache2' do + repo_name 'ceph-apache2' + uri "http://gitbuilder.ceph.com/apache2-deb-#{node['lsb']['codename']}-x86_64-basic/ref/master" + distribution distribution_codename + components ['main'] + key 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc' + end + apt_repository 'ceph-modfastcgi' do + repo_name 'ceph-modfastcgi' + uri "http://gitbuilder.ceph.com/libapache-mod-fastcgi-deb-#{node['lsb']['codename']}-x86_64-basic/ref/master" + distribution distribution_codename + components ['main'] + key 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc' + end + else + Log.info("Ceph's Apache and Apache FastCGI forks not available for this distribution") + end +end + diff --git a/recipes/radosgw_install.rb b/recipes/radosgw_install.rb new file mode 100644 index 0000000..7944d49 --- /dev/null +++ b/recipes/radosgw_install.rb @@ -0,0 +1,5 @@ +include_recipe 'ceph::_common_install' + +node['ceph']['radosgw']['packages'].each do |pck| + package pck +end