Permalink
Browse files

[COOK-1757] - platform_family and style

* use platform_family for platform checking
* update notifies syntax to "resource_type[resource_name]" instead of
  resources() lookup
* COOK-692 - delete config files dropped off by packages in conf.d
* dropped debian 4 support because all other platforms have the same
  values, and it is older than "old stable" debian release
  • Loading branch information...
1 parent e68be53 commit 2ef44f1f4c784d67090ee8947906ef6f53f93a76 @jtimberman jtimberman committed Oct 10, 2012
@@ -145,5 +145,5 @@
}
%w{ log_config logio }.each do |log_mod|
- default['apache']['default_modules'] << log_mod if ["redhat", "centos", "scientific", "fedora", "suse", "arch", "freebsd", "amazon"].include?(node['platform'])
+ default['apache']['default_modules'] << log_mod if ["rhel", "fedora", "suse", "arch", "freebsd"].include?(node['platform_family'])
end
@@ -1,27 +1,27 @@
-#
+#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2011, Opscode, Inc.
# License:: Apache License, Version 2.0
-#
+#
# 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.
-#
+#
default['apache']['mod_auth_openid']['checksum'] = "79e7ca52511d1230"
default['apache']['mod_auth_openid']['version'] = "0.6"
default['apache']['mod_auth_openid']['cache_dir'] = "/var/cache/mod_auth_openid"
default['apache']['mod_auth_openid']['dblocation'] = "#{node['apache']['mod_auth_openid']['cache_dir']}/mod_auth_openid.db"
-case node['platform']
+case node['platform_family']
when "freebsd"
default['apache']['mod_auth_openid']['configure_flags'] = [
"CPPFLAGS=-I/usr/local/include",
@@ -20,7 +20,7 @@
define :apache_conf do
template "#{node['apache']['dir']}/mods-available/#{params[:name]}.conf" do
source "mods/#{params[:name]}.conf.erb"
- notifies :restart, resources(:service => "apache2")
+ notifies :restart, "service[apache2]"
mode 0644
end
end
@@ -27,7 +27,7 @@
apache_conf params[:name]
end
- if platform?("redhat", "centos", "scientific", "fedora", "arch", "suse", "amazon", "freebsd")
+ if platform_family?("rhel", "fedora", "arch", "suse", "freebsd")
file "#{node['apache']['dir']}/mods-available/#{params[:name]}.load" do
content "LoadModule #{params[:name]}_module #{params[:module_path]}\n"
mode 0644
View
@@ -19,19 +19,18 @@
package "apache2" do
package_name node['apache']['package']
- action :install
end
service "apache2" do
- case node['platform']
- when "redhat","centos","scientific","fedora","suse","amazon"
+ case node['platform_family']
+ when "rhel", "fedora", "suse"
service_name "httpd"
# If restarted/reloaded too quickly httpd has a habit of failing.
# This may happen with multiple recipes notifying apache to restart - like
# during the initial bootstrap.
restart_command "/sbin/service httpd restart && sleep 1"
reload_command "/sbin/service httpd reload && sleep 1"
- when "debian","ubuntu"
+ when "debian"
service_name "apache2"
restart_command "/usr/sbin/invoke-rc.d apache2 restart && sleep 1"
reload_command "/usr/sbin/invoke-rc.d apache2 reload && sleep 1"
@@ -40,55 +39,40 @@
when "freebsd"
service_name "apache22"
end
- supports value_for_platform(
- "debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] },
- "ubuntu" => { "default" => [ :restart, :reload, :status ] },
- "redhat" => { "default" => [ :restart, :reload, :status ] },
- "centos" => { "default" => [ :restart, :reload, :status ] },
- "scientific" => { "default" => [ :restart, :reload, :status ] },
- "fedora" => { "default" => [ :restart, :reload, :status ] },
- "arch" => { "default" => [ :restart, :reload, :status ] },
- "suse" => { "default" => [ :restart, :reload, :status ] },
- "freebsd" => { "default" => [ :restart, :reload, :status ] },
- "amazon" => { "default" => [ :restart, :reload, :status ] },
- "default" => { "default" => [:restart, :reload ] }
- )
+ supports [:restart, :reload, :status]
action :enable
end
-if platform?("redhat", "centos", "scientific", "fedora", "arch", "suse", "freebsd", "amazon")
+if platform_family?("rhel", "fedora", "arch", "suse", "freebsd")
directory node['apache']['log_dir'] do
- mode 0755
- action :create
+ mode 00755
end
package "perl"
cookbook_file "/usr/local/bin/apache2_module_conf_generate.pl" do
source "apache2_module_conf_generate.pl"
- mode 0755
+ mode 00755
owner "root"
group node['apache']['root_group']
end
%w{sites-available sites-enabled mods-available mods-enabled}.each do |dir|
directory "#{node['apache']['dir']}/#{dir}" do
- mode 0755
+ mode 00755
owner "root"
group node['apache']['root_group']
- action :create
end
end
execute "generate-module-list" do
command "/usr/local/bin/apache2_module_conf_generate.pl #{node['apache']['lib_dir']} #{node['apache']['dir']}/mods-available"
- action :run
end
%w{a2ensite a2dissite a2enmod a2dismod}.each do |modscript|
template "/usr/sbin/#{modscript}" do
source "#{modscript}.erb"
- mode 0700
+ mode 00700
owner "root"
group node['apache']['root_group']
end
@@ -112,11 +96,13 @@
include_recipe "apache2::mod_deflate"
end
-if platform?("freebsd")
+if platform_family?("freebsd")
+
file "#{node['apache']['dir']}/Includes/no-accf.conf" do
action :delete
backup false
end
+
directory "#{node['apache']['dir']}/Includes" do
action :delete
end
@@ -125,93 +111,94 @@
httpd-languages.conf httpd-manual.conf httpd-mpm.conf
httpd-multilang-errordoc.conf httpd-ssl.conf httpd-userdir.conf
httpd-vhosts.conf}.each do |f|
+
file "#{node['apache']['dir']}/extra/#{f}" do
action :delete
backup false
end
+
end
+
directory "#{node['apache']['dir']}/extra" do
action :delete
end
+
end
directory "#{node['apache']['dir']}/ssl" do
- action :create
- mode 0755
+ mode 00755
owner "root"
group node['apache']['root_group']
end
directory "#{node['apache']['dir']}/conf.d" do
- action :create
- mode 0755
+ mode 00755
owner "root"
group node['apache']['root_group']
end
directory node['apache']['cache_dir'] do
- action :create
- mode 0755
+ mode 00755
owner "root"
group node['apache']['root_group']
end
template "apache2.conf" do
- case node['platform']
- when "redhat", "centos", "scientific", "fedora", "arch", "amazon"
+ case node['platform_family']
+ when "rhel", "fedora", "arch"
path "#{node['apache']['dir']}/conf/httpd.conf"
- when "debian","ubuntu"
+ when "debian"
path "#{node['apache']['dir']}/apache2.conf"
when "freebsd"
path "#{node['apache']['dir']}/httpd.conf"
end
source "apache2.conf.erb"
owner "root"
group node['apache']['root_group']
- mode 0644
- notifies :restart, resources(:service => "apache2")
+ mode 00644
+ notifies :restart, "service[apache2]"
end
-template "security" do
+template "apache2-conf-security" do
path "#{node['apache']['dir']}/conf.d/security"
source "security.erb"
owner "root"
group node['apache']['root_group']
- mode 0644
+ mode 00644
backup false
- notifies :restart, resources(:service => "apache2")
+ notifies :restart, "service[apache2]"
end
-template "charset" do
+template "apache2-conf-charset" do
path "#{node['apache']['dir']}/conf.d/charset"
source "charset.erb"
owner "root"
group node['apache']['root_group']
- mode 0644
+ mode 00644
backup false
- notifies :restart, resources(:service => "apache2")
+ notifies :restart, "service[apache2]"
end
template "#{node['apache']['dir']}/ports.conf" do
source "ports.conf.erb"
owner "root"
group node['apache']['root_group']
variables :apache_listen_ports => node['apache']['listen_ports'].map{|p| p.to_i}.uniq
- mode 0644
- notifies :restart, resources(:service => "apache2")
+ mode 00644
+ notifies :restart, "service[apache2]"
end
template "#{node['apache']['dir']}/sites-available/default" do
source "default-site.erb"
owner "root"
group node['apache']['root_group']
- mode 0644
- notifies :restart, resources(:service => "apache2")
+ mode 00644
+ notifies :restart, "service[apache2]"
end
node['apache']['default_modules'].each do |mod|
- recipe_name = mod =~ /^mod_/ ? mod : "mod_#{mod}"
- include_recipe "apache2::#{recipe_name}"
+ module_recipe_name = mod =~ /^mod_/ ? mod : "mod_#{mod}"
+ include_recipe "apache2::#{module_recipe_name}"
end
apache_site "default" if node['apache']['default_site_enabled']
View
@@ -19,27 +19,36 @@
# limitations under the License.
#
-case node['platform']
- when "debian", "ubuntu"
- package "libapache2-mod-apreq2" do
- action :install
- end
- when "centos", "redhat", "fedora", "amazon", "scientific"
- package "libapreq2" do
- action :install
- notifies :run, resources(:execute => "generate-module-list"), :immediately
- end
- # seems that the apreq lib is weirdly broken or something - it needs to be
- # loaded as "apreq", but on RHEL & derivitatives the file needs a symbolic
- # link to mod_apreq.so.
- link "/usr/lib64/httpd/modules/mod_apreq.so" do
- to "/usr/lib64/httpd/modules/mod_apreq2.so"
- only_if "test -f /usr/lib64/httpd/modules/mod_apreq2.so"
- end
- link "/usr/lib/httpd/modules/mod_apreq.so" do
- to "/usr/lib/httpd/modules/mod_apreq2.so"
- only_if "test -f /usr/lib/httpd/modules/mod_apreq2.so"
- end
+include_recipe "apache2"
+
+case node['platform_family']
+when "debian"
+
+ package "libapache2-mod-apreq2"
+
+when "rhel", "fedora"
+
+ package "libapreq2" do
+ notifies :run, "execute[generate-module-list]", :immediately
+ end
+
+ # seems that the apreq lib is weirdly broken or something - it needs to be
+ # loaded as "apreq", but on RHEL & derivitatives the file needs a symbolic
+ # link to mod_apreq.so.
+ link "/usr/lib64/httpd/modules/mod_apreq.so" do
+ to "/usr/lib64/httpd/modules/mod_apreq2.so"
+ only_if "test -f /usr/lib64/httpd/modules/mod_apreq2.so"
+ end
+
+ link "/usr/lib/httpd/modules/mod_apreq.so" do
+ to "/usr/lib/httpd/modules/mod_apreq2.so"
+ only_if "test -f /usr/lib/httpd/modules/mod_apreq2.so"
+ end
+end
+
+file "#{node['apache']['dir']}/conf.d/apreq.conf" do
+ action :delete
+ backup false
end
apache_module "apreq"
@@ -25,21 +25,18 @@
source 'mods/auth_cas.load.erb'
owner 'root'
group node['apache']['root_group']
- mode '0644'
+ mode 00644
end
else
case node['platform_family']
when "debian"
- package "libapache2-mod-auth-cas" do
- action :install
- end
+ package "libapache2-mod-auth-cas"
when "rhel", "fedora"
yum_package "mod_auth_cas" do
- action :install
notifies :run, "execute[generate-module-list]", :immediately
end
@@ -58,5 +55,5 @@
directory "#{node['apache']['cache_dir']}/mod_auth_cas" do
owner node['apache']['user']
group node['apache']['group']
- mode '0700'
+ mode 00700
end
Oops, something went wrong.

0 comments on commit 2ef44f1

Please sign in to comment.