]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cookbooks.git/commitdiff
Big refactor on install part
authorGuilhem Lettron <guilhem.lettron@optiflows.com>
Fri, 16 May 2014 15:54:45 +0000 (17:54 +0200)
committerGuilhem Lettron <guilhem.lettron@optiflows.com>
Fri, 16 May 2014 15:54:45 +0000 (17:54 +0200)
22 files changed:
attributes/default.rb
attributes/mds.rb
attributes/mon.rb
attributes/osd.rb
attributes/radosgw.rb
attributes/radosgw_apache2.rb [new file with mode: 0644]
libraries/utils.rb [new file with mode: 0644]
recipes/_common.rb
recipes/_common_install.rb [new file with mode: 0644]
recipes/apt.rb
recipes/default.rb [deleted file]
recipes/install.rb [new file with mode: 0644]
recipes/mds.rb
recipes/mds_install.rb [new file with mode: 0644]
recipes/mon.rb
recipes/mon_install.rb [new file with mode: 0644]
recipes/osd.rb
recipes/osd_install.rb [new file with mode: 0644]
recipes/radosgw.rb
recipes/radosgw_apache2.rb
recipes/radosgw_apache2_repo.rb [new file with mode: 0644]
recipes/radosgw_install.rb [new file with mode: 0644]

index 66dcf0d04de4aecd55b25eb549f2db3ab6730d94..e05bec6300a9997cd09f30116365f8bf1ceb173c 100644 (file)
@@ -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
index 8ab64d831f6b036579c6422f0dd15257b6ce0b3a..54c21cd90e7646635e8e01bf293cca9cc1d739d3 100644 (file)
@@ -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
index 6fad683683db70258df0b448539fbf3ea03b5af8..5d146e646d2b894ef5c92e1331908fef0936d9f9 100644 (file)
@@ -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'
index 48f32d28bb7181d95da92ce358ce5d19d59bb8b0..addbcce5e7fbeba0cd5e8de25e227d457870242a 100644 (file)
@@ -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'
index 9fa751793af1b9e1489d21666584adb2f5a71bcd..833f3c62d38cdf7173387fbd1accd98e04abc045 100644 (file)
 # 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 (file)
index 0000000..047c2a8
--- /dev/null
@@ -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 (file)
index 0000000..257472f
--- /dev/null
@@ -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
index 37a0da82adbd6b30b59ed6e02ddd77c6211b761d..8dbebfda05436f812a6822a1e3ed8a5662ea30bc 100644 (file)
@@ -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 (file)
index 0000000..171a227
--- /dev/null
@@ -0,0 +1 @@
+include_recipe 'ceph::repo' if node['ceph']['install_repo']
index f593cadcfa60f6ad37c44b07d9c208b7bb16811c..d101b006de73068112dda356dba7c4f64f6e5611 100644 (file)
@@ -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 (file)
index 7d1eb57..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Author:: Kyle Bader <kyle.bader@dreamhost.com>
-# 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 (file)
index 0000000..7d1eb57
--- /dev/null
@@ -0,0 +1,53 @@
+#
+# Author:: Kyle Bader <kyle.bader@dreamhost.com>
+# 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
index 93476cf42fa70e2552fa8cb5fbe44d9356561434..69ca3a5f1a454fbfc17423d28b9b97283fe33a26 100644 (file)
@@ -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 (file)
index 0000000..3ce533a
--- /dev/null
@@ -0,0 +1,5 @@
+include_recipe 'ceph::_common_install'
+
+node['ceph']['mds']['packages'].each do |pck|
+  package pck
+end
index 31fc96a408001cd1083ae8c5bf67d86a3839cd31..76a5d9173c8d58e51dff9f3b3a920af809c4375d 100644 (file)
@@ -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 (file)
index 0000000..557ad4c
--- /dev/null
@@ -0,0 +1,5 @@
+include_recipe 'ceph::_common_install'
+
+node['ceph']['mon']['packages'].each do |pck|
+  package pck
+end
index 337af2b15b5afe085c7ec3d83ff0613adeb17c16..fc2f9c6bd7407f439ee8a74012f38d090766fad3 100644 (file)
@@ -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 (file)
index 0000000..21991ad
--- /dev/null
@@ -0,0 +1,5 @@
+include_recipe 'ceph::_common_install'
+
+node['ceph']['osd']['packages'].each do |pck|
+  package pck
+end
index 4c86cc71fdec2a62869a6410a85f0fa4bd814083..7fb59032b7975036ffc31846a7608c472bd6b618 100644 (file)
 
 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")
index 5402a1d264e5741042fbdb456210d0f31a471e09..9f23e51ae0d4bc0e825fe4eacc67fe703d74aae1 100644 (file)
 # 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 (file)
index 0000000..df5cf3f
--- /dev/null
@@ -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 (file)
index 0000000..7944d49
--- /dev/null
@@ -0,0 +1,5 @@
+include_recipe 'ceph::_common_install'
+
+node['ceph']['radosgw']['packages'].each do |pck|
+  package pck
+end