Permalink
Browse files

[drupal]: adding the drupal_module definition

  • Loading branch information...
1 parent ff1123a commit 039416fb546afe95b549d6571b00651ecc3ffe17 @mdxp committed Mar 10, 2011
Showing with 44 additions and 0 deletions.
  1. +2 −0 drupal/attributes/default.rb
  2. +42 −0 drupal/definitions/drupal_module.rb
@@ -32,3 +32,5 @@
default[:drupal][:drush][:version] = "4.2"
default[:drupal][:drush][:checksum] = "6ab024cdec530223a008fb3ec3e5a94f478c8a999038ffc181561fbb4e7c3872"
default[:drupal][:drush][:dir] = "/usr/local/drush"
+
+default[:drupal][:modules] = ["views", ["webform","3.9"]]
@@ -0,0 +1,42 @@
+#
+# Author:: Marius Ducea (marius@promethost.com)
+# Cookbook Name:: drupal
+# Definition:: drupal_module
+#
+# Copyright 2010, Promet Solutions
+#
+# 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.
+#
+
+define :drupal_module, :action => :install, :dir => nil, :version => nil do
+ case params[:action]
+ when :install
+ if params[:dir] == nil then
+ log("drupal_module_install requires a working drupal dir") { level :fatal }
+ raise "drupal_module_install requires a working drupal dir"
+ end
+ execute "drush_dl_module #{params[:name]}" do
+ cwd params[:dir]
+ command "#{node[:drupal][:drush][:dir]}/drush -y dl #{params[:name]}"
+ not_if "#{node[:drupal][:drush][:dir]}/drush -r #{params[:dir]} pm-list |grep '(#{params[:name]})' |grep '#{params[:version]}'"
+ end
+ execute "drush_en_module #{params[:name]}" do
+ cwd params[:dir]
+ command "#{node[:drupal][:drush][:dir]}/drush -y en #{params[:name]}"
+ not_if "#{node[:drupal][:drush][:dir]}/drush -r #{params[:dir]} pm-list |grep '(#{params[:name]})' |grep -i 'enabled'"
+ end
+ else
+ log "drupal_source action #{params[:name]} is unrecognized."
+ end
+end
+

0 comments on commit 039416f

Please sign in to comment.