Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
default[:drupal][:site][:admin] = "admin"
default[:drupal][:site][:pass] = "drupaladmin"
default[:drupal][:site][:name] = "Drupal7"
default[:drupal][:webserver] = "apache2"
default[:drupal][:skip_php] = false

::Chef::Node.send(:include, Opscode::OpenSSL::Password)

Expand Down
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
recipe "drupal::cron", "Sets up the default drupal cron"
recipe "drupal::drush", "Installs drush - a command line shell and scripting interface for Drupal"

%w{ php apache2 mysql openssl }.each do |cb|
%w{ php apache2 mysql openssl nginx }.each do |cb|
depends cb
end

%w{ debian ubuntu }.each do |os|
%w{ debian ubuntu centos redhat amazon scientific }.each do |os|
supports os
end

54 changes: 38 additions & 16 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
# limitations under the License.
#

include_recipe %w{apache2 apache2::mod_php5 apache2::mod_rewrite apache2::mod_expires}
include_recipe %w{php php::module_mysql php::module_gd}
if node[:drupal][:webserver] == "apache2"
include_recipe %w{apache2 apache2::mod_php5 apache2::mod_rewrite apache2::mod_expires}
elsif node[:drupal][:webserver] == "nginx"
# include_recipe %w{nginx}
else
log("Only webservers currently supported: apache2 and nginx. You have: #{node[:drupal][:webserver]}") { level :warn }
end

include_recipe %w{php php::module_mysql php::module_gd} unless node[:drupal][:skip_php]
include_recipe "drupal::drush"
include_recipe "mysql::server"

Expand All @@ -44,10 +51,7 @@

execute "create #{node[:drupal][:db][:database]} database" do
command "/usr/bin/mysqladmin -u root -p#{node[:mysql][:server_root_password]} create #{node[:drupal][:db][:database]}"
not_if do
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.list_dbs.include?(node[:drupal][:db][:database])
end
not_if "/usr/bin/mysql -u root -p#{node[:mysql][:server_root_password]} -e 'show databases' | grep -q #{node[:drupal][:db][:database]}"
end

execute "download-and-install-drupal" do
Expand Down Expand Up @@ -84,16 +88,34 @@
end
end

web_app "drupal" do
template "drupal.conf.erb"
docroot "#{node[:drupal][:dir]}"
server_name server_fqdn
server_aliases node.fqdn
end

include_recipe "drupal::cron"

execute "disable-default-site" do
command "sudo a2dissite default"
notifies :reload, resources(:service => "apache2"), :delayed

if node[:drupal][:webserver] == "apache2"
web_app node[:drupal][:site][:name] do
template "drupal.conf.erb"
docroot "#{node[:drupal][:dir]}"
server_name server_fqdn
server_aliases node.fqdn
end

execute "disable-default-site" do
command "sudo a2dissite default"
notifies :reload, resources(:service => "apache2"), :delayed
end
end

if node[:drupal][:webserver] == "nginx"
template "#{node[:nginx][:dir]}/sites-enabled/#{node[:drupal][:site][:name]}" do
source "sites.conf.erb"
owner "root"
group "root"
mode "0600"
variables(
:docroot => "#{node[:drupal][:dir]}",
:server_name => server_fqdn
)
end

nginx_site node[:drupal][:site][:name]
end
2 changes: 1 addition & 1 deletion recipes/drush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

include_recipe %w{php php::module_mysql php::module_gd}
include_recipe %w{php php::module_mysql php::module_gd} unless node[:drupal][:skip_php]

remote_file "#{node[:drupal][:src]}/drush-All-versions-#{node[:drupal][:drush][:version]}.tar.gz" do
checksum node[:drupal][:drush][:checksum]
Expand Down
40 changes: 40 additions & 0 deletions templates/default/sites.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
server {
listen 80;
server_name <%= @server_name %>;

access_log <%= node[:nginx][:log_dir] %>/<%= @server_name %>.access.log;

root <%= @docroot %>;
index index.php;

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}

location ~ (\.php)$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}

## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
}


## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}