Skip to content

Commit

Permalink
[drupal]: adding the drupal_module definition
Browse files Browse the repository at this point in the history
  • Loading branch information
mdxp committed Mar 10, 2011
1 parent ff1123a commit 039416f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drupal/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
42 changes: 42 additions & 0 deletions drupal/definitions/drupal_module.rb
Original file line number Diff line number Diff line change
@@ -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.