Skip to content
Browse files

apache2 cookbook version 0.99.0

* support archlinux
* use Chef::Config[:file_cache_path] to download instead of /tmp
  • Loading branch information...
1 parent e497b12 commit 173256be3a5a3039e2a70531d9af81176b75a628 @jtimberman jtimberman committed
View
26 README.rdoc
@@ -6,7 +6,7 @@ Complete Debian/Ubuntu style Apache2 configuration.
Debian or Ubuntu preferred.
-Red Hat/CentOS and Fedora can be used but will be converted to a Debian/Ubuntu style Apache as it's far easier to manage with chef.
+Red Hat, CentOS, Fedora and ArchLinux can be used but will be converted to a Debian/Ubuntu style Apache as it's far easier to manage with Chef.
= ATTRIBUTES:
@@ -27,32 +27,32 @@ For Red Hat, CentOS and Fedora you should first disable selinux as it's not supp
== Defines:
-* apache_module: sets up an Apache module.
-* apache_conf: sets up a config file for an apache module.
-* apache_site: sets up a vhost site. The conf file must be available.
-* web_app: copies the template for a web app and enables it as a site via apache_site.
+* +apache_module+: sets up an Apache module.
+* +apache_conf+: sets up a config file for an apache module.
+* +apache_site+: sets up a vhost site. The conf file must be available.
+* +web_app+: copies the template for a web app and enables it as a site via +apache_site+.
== Web Apps:
Various applications that can be set up with Apache as the front end, such as PHP, Django, Rails and others can use the web_app define to set up the template and the Apache site. The define is kind of dumb, so the template needs have the application implementation settings, since we don't know what your app is or what is needed from Apache.
-We only prototype one parameter for the web_app define, "template". This is used to specify the name of the template to use in the current cookbook. When you use web_app, you can set up any parameters you want to use in your template. They will get passed to the template through the params hash. For example, the sample web_app.conf.erb template in this cookbook makes use of these.
+We only prototype one parameter for the +web_app+ define, "template". This is used to specify the name of the template to use in the current cookbook. When you use +web_app+, you can set up any parameters you want to use in your template. They will get passed to the template through the params hash. For example, the sample +web_app.conf.erb+ template in this cookbook makes use of these.
-* docroot
-* server_name
-* server_aliases
+* +docroot+
+* +server_name+
+* +server_aliases+
-These are available as @params[:docroot], @params[:server_name], @params[:server_aliases] within the template.
+These are available as +params[:docroot]+, +params[:server_name]+, +params[:server_aliases]+ prefixed with an @ within the template.
-If 'cookbook' and 'template' are not specified, the current cookbook's templates/default/web_app.conf.erb will be used. If this template is not suitable for your application, copy it to your cookbook and customize as needed.
+If 'cookbook' and 'template' are not specified, the current cookbook's +templates/default/web_app.conf.erb+ will be used. If this template is not suitable for your application, copy it to your cookbook and customize as needed.
== God Monitor:
-There's a new recipe, apache2::god_monitor. You will need to make sure to include the 'god' recipe before using the apache2::god_monitor recipe in your cookbook.
+There's a new recipe, +apache2::god_monitor+. You will need to make sure to include the 'god' recipe before using the +apache2::god_monitor+ recipe in your cookbook.
== OpenID Auth
-Installs the mod_auth_openid module from source. Specify an array of OpenIDs that are allowed to authenticate with the attribute apache[:allowed_openids]. Use the following in a vhost to protect with OpenID authentication:
+Installs the +mod_auth_openid+ module from source. Specify an array of OpenIDs that are allowed to authenticate with the attribute +apache[:allowed_openids]+. Use the following in a vhost to protect with OpenID authentication:
AuthOpenIDEnabled On
AuthOpenIDDBLocation /var/cache/apache2/mod_auth_openid.db
View
10 attributes/default.rb
@@ -25,18 +25,28 @@
set[:apache][:user] = "apache"
set[:apache][:binary] = "/usr/sbin/httpd"
set[:apache][:icondir] = "/var/www/icons/"
+ set[:apache][:cache_dir] = "/var/cache/httpd"
when "debian","ubuntu"
set[:apache][:dir] = "/etc/apache2"
set[:apache][:log_dir] = "/var/log/apache2"
set[:apache][:user] = "www-data"
set[:apache][:binary] = "/usr/sbin/apache2"
set[:apache][:icondir] = "/usr/share/apache2/icons"
+ set[:apache][:cache_dir] = "/var/cache/apache2"
+when "arch"
+ set[:apache][:dir] = "/etc/httpd"
+ set[:apache][:log_dir] = "/var/log/httpd"
+ set[:apache][:user] = "http"
+ set[:apache][:binary] = "/usr/sbin/httpd"
+ set[:apache][:icondir] = "/usr/share/httpd/icons"
+ set[:apache][:cache_dir] = "/var/cache/httpd"
else
set[:apache][:dir] = "/etc/apache2"
set[:apache][:log_dir] = "/var/log/apache2"
set[:apache][:user] = "www-data"
set[:apache][:binary] = "/usr/sbin/apache2"
set[:apache][:icondir] = "/usr/share/apache2/icons"
+ set[:apache][:cache_dir] = "/var/cache/apache2"
end
###
View
2 metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs and configures all aspects of apache2 using Debian style symlinks with helper definitions"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.12.3"
+version "0.99.0"
recipe "apache2", "Main Apache configuration"
recipe "apache2::mod_alias", "Apache module 'alias' with config file"
recipe "apache2::mod_auth_basic", "Apache module 'auth_basic'"
View
27 recipes/default.rb
@@ -23,6 +23,8 @@
package_name "httpd"
when "debian","ubuntu"
package_name "apache2"
+ when "arch"
+ package_name "apache"
end
action :install
end
@@ -40,6 +42,8 @@
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"
+ when "arch"
+ service_name "httpd"
end
supports value_for_platform(
"debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] },
@@ -47,12 +51,13 @@
"centos" => { "default" => [ :restart, :reload, :status ] },
"redhat" => { "default" => [ :restart, :reload, :status ] },
"fedora" => { "default" => [ :restart, :reload, :status ] },
+ "arch" => { "default" => [ :restart, :reload, :status ] },
"default" => { "default" => [:restart, :reload ] }
)
action :enable
end
-if platform?("centos", "redhat", "fedora", "suse")
+if platform?("centos", "redhat", "fedora", "suse", "arch")
directory node[:apache][:log_dir] do
mode 0755
action :create
@@ -76,12 +81,11 @@
execute "generate-module-list" do
if node[:kernel][:machine] == "x86_64"
- libdir = "lib64"
+ libdir = value_for_platform("arch" => { "default" => "lib" }, "default" => "lib64")
else
libdir = "lib"
end
command "/usr/local/bin/apache2_module_conf_generate.pl /usr/#{libdir}/httpd/modules /etc/httpd/mods-available"
-
action :run
end
@@ -118,9 +122,22 @@
group "root"
end
+directory "#{node[:apache][:dir]}/conf.d" do
+ action :create
+ mode 0755
+ owner "root"
+ group "root"
+end
+
+directory node[:apache][:cache_dir] do
+ action :create
+ mode 0755
+ owner node[:apache][:user]
+end
+
template "apache2.conf" do
case node[:platform]
- when "centos","redhat","fedora"
+ when "centos","redhat","fedora","arch"
path "#{node[:apache][:dir]}/conf/httpd.conf"
when "debian","ubuntu"
path "#{node[:apache][:dir]}/apache2.conf"
@@ -183,7 +200,7 @@
include_recipe "apache2::mod_mime"
include_recipe "apache2::mod_negotiation"
include_recipe "apache2::mod_setenvif"
-include_recipe "apache2::mod_log_config" if platform?("centos", "redhat", "suse")
+include_recipe "apache2::mod_log_config" if platform?("centos", "redhat", "suse", "arch")
# uncomment to get working example site on centos/redhat/fedora
#apache_site "default"
View
38 recipes/mod_auth_openid.rb
@@ -17,29 +17,53 @@
# limitations under the License.
#
-%w{ apache2-prefork-dev libopkele-dev libopkele3 }.each do |pkg|
- package pkg
+openid_dev_pkgs = value_for_platform(
+ "ubuntu" => { "default" => %w{ apache2-prefork-dev libopkele-dev libopkele3 } },
+ "debian" => { "default" => %w{ apache2-prefork-dev libopkele-dev libopkele3 } },
+ "arch" => { "default" => ["libopkele"] }
+)
+
+case node[:platform]
+when "arch"
+ include_recipe "pacman"
+ package "tidyhtml"
+end
+
+openid_dev_pkgs.each do |pkg|
+ case node[:platform]
+ when "arch"
+ pacman_aur pkg do
+ action [:build, :install]
+ end
+ else
+ package pkg
+ end
end
-remote_file "/tmp/mod_auth_openid-0.4.tar.gz" do
+remote_file "#{Chef::Config[:file_cache_path]}/mod_auth_openid-0.4.tar.gz" do
source "http://butterfat.net/releases/mod_auth_openid/mod_auth_openid-0.4.tar.gz"
mode 0644
end
bash "install mod_auth_openid" do
- cwd "/tmp"
+ cwd Chef::Config[:file_cache_path]
code <<-EOH
tar zxvf mod_auth_openid-0.4.tar.gz
cd mod_auth_openid-0.4 && ./configure
perl -pi -e "s/-i -a -n 'authopenid'/-i -n 'authopenid'/g" Makefile
make && make install
EOH
- not_if { File.exists?("/usr/lib/apache2/modules/mod_auth_openid.so") }
+ case node[:platform]
+ when "arch"
+ not_if { File.exists?("/usr/lib/httpd/modules/mod_auth_openid.so") }
+ else
+ not_if { File.exists?("/usr/lib/apache2/modules/mod_auth_openid.so") }
+ end
end
-file "/var/cache/apache2/mod_auth_openid.db" do
+file "#{node[:apache][:cache_dir]}/mod_auth_openid.db" do
owner node[:apache][:user]
- mode 0600
+ mode 0640
end
template "#{node[:apache][:dir]}/mods-available/authopenid.load" do
View
10 recipes/mod_fcgid.rb
@@ -19,7 +19,7 @@
if platform?("debian", "ubuntu")
package "libapache2-mod-fcgid"
-elsif platform?("centos", "redhat", "fedora")
+elsif platform?("centos", "redhat", "fedora", "arch")
package "mod_fcgid" do
notifies :run, resources(:execute => "generate-module-list"), :immediately
end
@@ -33,10 +33,10 @@
package "httpd-devel"
bash "install-fcgid" do
code <<-EOH
-(cd /tmp; wget http://superb-east.dl.sourceforge.net/sourceforge/mod-fcgid/mod_fcgid.2.2.tgz)
-(cd /tmp; tar zxvf mod_fcgid.2.2.tgz)
-(cd /tmp; perl -pi -e 's!/usr/local/apache2!#{apache_lib_path}!g' ./mod_fcgid.2.2/Makefile)
-(cd /tmp/mod_fcgid.2.2; make install)
+(cd #{Chef::Config[:file_cache_path]}; wget http://superb-east.dl.sourceforge.net/sourceforge/mod-fcgid/mod_fcgid.2.2.tgz)
+(cd #{Chef::Config[:file_cache_path]}; tar zxvf mod_fcgid.2.2.tgz)
+(cd #{Chef::Config[:file_cache_path]}; perl -pi -e 's!/usr/local/apache2!#{apache_lib_path}!g' ./mod_fcgid.2.2/Makefile)
+(cd #{Chef::Config[:file_cache_path]}/mod_fcgid.2.2; make install)
EOH
end
end
View
2 recipes/mod_log_config.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-if platform?("centos", "redhat", "fedora", "suse")
+if platform?("centos", "redhat", "fedora", "suse", "arch")
apache_module "log_config"
else
include_recipe "apache2"
View
5 recipes/mod_php5.rb
@@ -22,6 +22,11 @@
package "libapache2-mod-php5" do
action :install
end
+when "arch"
+ package "php-apache" do
+ action :install
+ notifies :run, resources(:execute => "generate-module-list"), :immediately
+ end
when "centos", "redhat", "fedora"
package "php" do
action :install
View
2 recipes/mod_wsgi.rb
@@ -20,7 +20,7 @@
case node[:platform]
when "debian","ubuntu"
package "libapache2-mod-wsgi"
-when "redhat","centos","fedora"
+when "redhat","centos","fedora", "arch"
package "mod_wsgi"
end
View
2 templates/default/apache2.conf.erb
@@ -22,6 +22,8 @@ LockFile logs/accept.lock
PidFile /var/run/apache2.pid
<% elsif node[:platform] == "centos" || node[:platform] == "redhat" || node[:platform] == "fedora" -%>
PidFile /var/run/httpd.pid
+<% elsif node[:platform] == "arch" -%>
+PidFile /var/run/httpd/httpd.pid
<% else -%>
PidFile logs/httpd.pid
<% end -%>
View
5 templates/default/mods/authopenid.load.erb
@@ -1 +1,6 @@
+<% case node[:platform] -%>
+<% when "arch" -%>
+LoadModule authopenid_module /usr/lib/httpd/modules/mod_auth_openid.so
+<% else -%>
LoadModule authopenid_module /usr/lib/apache2/modules/mod_auth_openid.so
+<% end -%>
View
5 templates/default/mods/mime.conf.erb
@@ -4,7 +4,12 @@
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
+<% case node[:platform] -%>
+<% when "arch" -%>
+TypesConfig <%= node['apache']['dir'] %>/conf/mime.types
+<% else -%>
TypesConfig /etc/mime.types
+<% end -%>
#
# AddType allows you to add to or override the MIME configuration

0 comments on commit 173256b

Please sign in to comment.
Something went wrong with that request. Please try again.