diff --git a/attributes/radosgw.rb b/attributes/radosgw.rb index 36aea39..bc7b68c 100644 --- a/attributes/radosgw.rb +++ b/attributes/radosgw.rb @@ -20,3 +20,4 @@ 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 diff --git a/recipes/radosgw.rb b/recipes/radosgw.rb index 4e4e263..6cbe46d 100644 --- a/recipes/radosgw.rb +++ b/recipes/radosgw.rb @@ -17,11 +17,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -include_recipe "apache2" - packages = %w{ - radosgw - libapache2-mod-fastcgi + radosgw } if node['ceph']['install_debug'] @@ -32,48 +29,24 @@ if node['ceph']['install_debug'] end packages.each do |pkg| - package pkg do - action :upgrade - end + package pkg do + action :upgrade + end end cookbook_file "/etc/init.d/radosgw" do - source "radosgw" - mode 0755 - owner "root" - group "root" + source "radosgw" + mode 0755 + owner "root" + group "root" end service "radosgw" do - service_name "radosgw" - supports :restart => true - action[:enable,:start] + service_name "radosgw" + supports :restart => true + action[:enable,:start] end -apache_module "fastcgi" do - conf true +if node["ceph"]["radosgw"]["webserver_companion"] + include_recipe "ceph::radosgw_#{node["ceph"]["radosgw"]["webserver_companion"]}" end - -apache_module "rewrite" do - conf false -end - -template "/etc/apache2/sites-available/rgw.conf" do - source "rgw.conf.erb" - mode 0400 - owner "root" - group "root" - variables( - :ceph_api_fqdn => node['ceph']['radosgw']['api_fqdn'], - :ceph_admin_email => node['ceph']['radosgw']['admin_email'], - :ceph_rgw_addr => node['ceph']['radosgw']['rgw_addr'] - ) - if ::File.exists?("#{node['apache']['dir']}/sites-enabled/rgw.conf") - notifies :restart, "service[apache2]" - end -end - -apache_site "rgw.conf" do - enable enable_setting -end - diff --git a/recipes/radosgw_apache2.rb b/recipes/radosgw_apache2.rb new file mode 100644 index 0000000..c6c23a3 --- /dev/null +++ b/recipes/radosgw_apache2.rb @@ -0,0 +1,32 @@ +# +# Author:: Kyle Bader +# Cookbook Name:: ceph +# Recipe:: radosgw_apache2 +# +# 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. + +include_recipe "apache2" +include_recipe "apache2::mod_fastcgi" + +apache_module "rewrite" do + conf false +end + +web_app "rgw" do + template "rgw.conf.erb" + server_name node['ceph']['radosgw']['api_fqdn'] + admin_email node['ceph']['radosgw']['admin_email'] + ceph_rgw_addr node['ceph']['radosgw']['rgw_addr'] +end diff --git a/templates/default/rgw.conf.erb b/templates/default/rgw.conf.erb index 9a22c7a..3bd8e5d 100644 --- a/templates/default/rgw.conf.erb +++ b/templates/default/rgw.conf.erb @@ -1,15 +1,15 @@ <% if node['ceph']['radosgw']['rgw_port'] -%> FastCgiExternalServer /var/www/dummyradosgw.fcgi -host 127.0.0.1:<%= node['ceph']['radosgw']['rgw_port'] %> <% else -%> -FastCgiExternalServer /var/www/dummyradosgw.fcgi -socket /var/run/ceph/radosgw.client.radosgw.<%= node[:hostname] %> +FastCgiExternalServer /var/www/dummyradosgw.fcgi -socket /var/run/ceph/radosgw.client.radosgw.<%= node['hostname'] %> <% end -%> LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" proxy_combined LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" proxy_debug -> - ServerName <%= @ceph_api_fqdn %> - ServerAdmin <%= @ceph_admin_email %> +> + ServerName <%= @params[:server_name] %> + ServerAdmin <%= node["ceph"]["radosgw"]["admin_email"] %> DocumentRoot /var/www/ RewriteEngine On