Created
May 12, 2013 13:20
-
-
Save sbates/5563535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: tomcat | |
# Definitions:: deploy_tomcat_app | |
# | |
# Author:: Sascha Bates | |
define :deploy_tomcat_app, | |
:artifact_type => "latest", #latest or static | |
:artifact => "", | |
:group_id => "", | |
:version => "", | |
:repo => "", | |
:filetype => "", | |
:properties_dir => "", | |
:svc_name => "", | |
:homedir => "/opt/tomcat", | |
:action => "deploy" do | |
svc_name = params[:svc_name] || node[:tomcat][:svc_name] | |
homedir = params[:homedir] || node[:tomcat][:home] | |
src = "#{Chef::Config[:file_cache_path]}/#{params[:artifact]}-#{params[:version]}.#{params[:filetype]}" | |
dst = "#{homedir}/webapps/#{params[:artifact]}.#{params[:filetype]}" | |
service svc_name do | |
action :nothing | |
end | |
execute "deploy_#{params[:artifact]}" do | |
Chef::Log.debug("deploying #{params[:artifact]} to #{homedir}/webapps") | |
command "cp #{src} #{dst}" | |
notifies :restart, "service[#{svc_name}]" | |
action :nothing | |
end | |
art_action = "download_#{params[:artifact_type]}" | |
artifact params[:artifact] do | |
action art_action | |
group_id params[:group_id] | |
repo params[:repo] | |
version params[:version] | |
filetype params[:filetype] | |
notifies :stop, ("service[#{svc_name}]"), :immediately | |
notifies :delete, ("directory[#{homedir}/webapps/#{params[:artifact]}]"), :immediately | |
notifies :run, ("execute[deploy_#{params[:artifact]}]") | |
end | |
# This block exists to allow a deployed app to be deleted prior to deploying the new one | |
directory "#{homedir}/webapps/#{params[:artifact]}" do | |
action :nothing | |
recursive true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment