Skip to content

Commit

Permalink
Modify Apache attributes and recipes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
bossato committed Feb 7, 2015
1 parent 0189eb9 commit 4e780db
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 53 deletions.
42 changes: 42 additions & 0 deletions site-cookbooks/apache/attributes/conf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
###
# Conf Settings
###

# General
default['apache']['port'] = 80
default['apache']['port_ssl'] = 443
default['apache']['directory_index'] = "index.php index.html"

# User
default['apache']['user'] = "www"
default['apache']['group'] = "www"
default['apache']['server_admin'] = "you@example.com"

# Server
default['apache']['server_name'] = "locaohost"
default['apache']['document_root'] = "/usr/local/apache2/htdocs"

# Logs
default['apache']['access_log'] = "#{default['apache']['dir']}/logs/access_log"
default['apache']['error_log'] = "#{default['apache']['dir']}/logs/error_log"

# Prefork
default['apache']['prefork']['start_servers'] = 5
default['apache']['prefork']['min_spare_servers'] = 5
default['apache']['prefork']['max_spare_servers'] = 10
default['apache']['prefork']['max_clients'] = 150
default['apache']['prefork']['max_requests_perchild'] = 0

# Worker
default['apache']['worker']['start_servers'] = 2
default['apache']['worker']['min_spare_threads'] = 25
default['apache']['worker']['max_spare_threads'] = 75
default['apache']['worker']['max_clients'] = 150
default['apache']['worker']['max_requests_perchild'] = 0
default['apache']['worker']['threads_perchild'] = 25

# SSL
default['apache']['ssl']['session_cache_timeout'] = 300
default['apache']['ssl']['certificate_file'] = ""
default['apache']['ssl']['certificate_key_file'] = ""
default['apache']['ssl']['certificate_chain_file'] = ""
44 changes: 0 additions & 44 deletions site-cookbooks/apache/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,3 @@

## Include library
include_attribute "apache::lib"


###
# Conf Settings
###

# General
default['apache']['port'] = 80
default['apache']['port_ssl'] = 443
default['apache']['directory_index'] = "index.php index.html"

# User
default['apache']['user'] = "www"
default['apache']['group'] = "www"
default['apache']['server_admin'] = "you@example.com"

# Server
default['apache']['server_name'] = "locaohost"
default['apache']['document_root'] = "/usr/local/apache2/htdocs"

# Logs
default['apache']['access_log'] = "#{default['apache']['dir']}/logs/access_log"
default['apache']['error_log'] = "#{default['apache']['dir']}/logs/error_log"

# Prefork
default['apache']['prefork']['start_servers'] = 5
default['apache']['prefork']['min_spare_servers'] = 5
default['apache']['prefork']['max_spare_servers'] = 10
default['apache']['prefork']['max_clients'] = 150
default['apache']['prefork']['max_requests_perchild'] = 0

# Worker
default['apache']['worker']['start_servers'] = 2
default['apache']['worker']['min_spare_threads'] = 25
default['apache']['worker']['max_spare_threads'] = 75
default['apache']['worker']['max_clients'] = 150
default['apache']['worker']['max_requests_perchild'] = 0
default['apache']['worker']['threads_perchild'] = 25

# SSL
default['apache']['ssl']['session_cache_timeout'] = 300
default['apache']['ssl']['certificate_file'] = ""
default['apache']['ssl']['certificate_key_file'] = ""
default['apache']['ssl']['certificate_chain_file'] = ""
Binary file not shown.
40 changes: 40 additions & 0 deletions site-cookbooks/apache/recipes/conf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Cookbook Name:: apache
# Recipe:: conf
#
# Copyright 2015, Kazuya Sato
#
# All rights reserved - Do Not Redistribute
#

# Modify conf
template "#{node['apache']['dir']}/conf/httpd.conf" do
source "httpd.conf.erb"
owner node['apache']['install_user']
group node['apache']['install_group']
mode 00644
notifies :run, 'bash[restart apache]', :immediately
end


# Modify extra conf
for include_file in node['apache']['include_files']
template "#{node['apache']['dir']}/conf/extra/#{include_file}.conf" do
source "#{include_file}.conf.erb"
owner node['apache']['install_user']
group node['apache']['install_group']
mode 00644
notifies :run, 'bash[restart apache]', :immediately
end
end


# Bashs
bash "restart apache" do
action :nothing
flags '-ex'
user node['apache']['install_user']
code <<-EOH
#{node['apache']['dir']}/bin/apachectl restart
EOH
end
9 changes: 0 additions & 9 deletions site-cookbooks/apache/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,3 @@
#{node['apache']['dir']}/bin/apachectl start
EOH
end

bash "restart apache" do
action :nothing
flags '-ex'
user node['apache']['install_user']
code <<-EOH
#{node['apache']['dir']}/bin/apachectl restart
EOH
end

0 comments on commit 4e780db

Please sign in to comment.