diff --git a/libraries/provider_file_deploy.rb b/libraries/provider_file_deploy.rb index c73ffa4..39b6b12 100644 --- a/libraries/provider_file_deploy.rb +++ b/libraries/provider_file_deploy.rb @@ -27,24 +27,16 @@ def initialize(new_resource, run_context) @deploy_resource = new_resource @new_resource = Chef::Resource::File.new(@deploy_resource.name) @new_resource.path ::File.join(@deploy_resource.destination, ::File.basename(@deploy_resource.repository)) - @new_resource.content @deploy_resource.repository - unless @deploy_resource.revision == "HEAD" - @new_resource.checksum @deploy_resource.revision - end + @new_resource.owner @deploy_resource.user @new_resource.group @deploy_resource.group provider = @new_resource.provider @action = action - @current_resource = nil - @run_context = run_context - @converge_actions = nil + super(@new_resource, run_context) if defined?(super) end def target_revision - unless @new_resource.checksum - action_sync - end - @target_revision ||= @new_resource.checksum + action_sync end alias :revision_slug :target_revision @@ -59,14 +51,21 @@ def set_content unless compare_content converge_by("stage local file #{@new_resource.content} to #{@new_resource.path}") do backup @new_resource.path if ::File.exists?(@new_resource.path) - ::FileUtils.cp_r(@new_resource.content, @new_resource.path) - Chef::Log.info("#{@new_resource.content} copied to #{@new_resource.path}") - @new_resource.updated_by_last_action(true) + ::FileUtils.cp_r(@deploy_resource.repository, @new_resource.path) end end end + def compare_content - checksum(@current_resource.path) == checksum(@new_resource.content) + checksum(@deploy_resource.repository) == checksum(@new_resource.path) + end + + def contents_changed? + compare_content + end + + def do_contents_changes + set_content end private @@ -97,8 +96,10 @@ def create_dir_unless_exists(dir) def purge_old_staged_files converge_by("purge old staged files") do Dir.glob( "#{@deploy_resource.destination}/*" ).each do |direntry| - FileUtils.rm_rf( direntry ) unless direntry == @new_resource.path - Chef::Log.info("#{@new_resource} purged old file #{direntry}") + unless direntry == @new_resource.path + FileUtils.rm_rf( direntry ) + Chef::Log.info("#{@new_resource} purged old file #{direntry}") + end end end end diff --git a/libraries/provider_remote_file_deploy.rb b/libraries/provider_remote_file_deploy.rb index 234411b..1f9f245 100644 --- a/libraries/provider_remote_file_deploy.rb +++ b/libraries/provider_remote_file_deploy.rb @@ -28,22 +28,15 @@ def initialize(new_resource, run_context) @new_resource = Chef::Resource::RemoteFile.new(@deploy_resource.name) @new_resource.path ::File.join(@deploy_resource.destination, ::File.basename(@deploy_resource.repository)) @new_resource.source @deploy_resource.repository - unless @deploy_resource.revision == "HEAD" - @new_resource.checksum @deploy_resource.revision - end + @new_resource.owner @deploy_resource.user @new_resource.group @deploy_resource.group @action = action - @current_resource = nil - @run_context = run_context - @converge_actions = nil + super(@new_resource, run_context) if defined?(super) end def target_revision - unless @new_resource.checksum - action_sync - end - @target_revision ||= @new_resource.checksum + action_sync end alias :revision_slug :target_revision @@ -81,8 +74,10 @@ def create_dir_unless_exists(dir) def purge_old_downloads converge_by("purge old downloads") do Dir.glob( "#{@deploy_resource.destination}/*" ).each do |direntry| - FileUtils.rm_rf( direntry ) unless direntry == @new_resource.path - Chef::Log.info("#{@new_resource} purged old download #{direntry}") + unless direntry == @new_resource.path + FileUtils.rm_rf( direntry ) + Chef::Log.info("#{@new_resource} purged old download #{direntry}") + end end end end diff --git a/metadata.rb b/metadata.rb index a45ce69..c1c3ef1 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,10 +4,10 @@ license "Apache 2.0" description "Deploys and configures Java-based applications" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "3.0.1" +version "3.0.2" %w{ java tomcat }.each do |cb| depends cb end -depends "application", "~> 3.0" +depends "application", "~> 4.1" diff --git a/providers/java_webapp.rb b/providers/java_webapp.rb index 4b551f4..a16b79b 100644 --- a/providers/java_webapp.rb +++ b/providers/java_webapp.rb @@ -46,7 +46,7 @@ def create_hierarchy %w{ log pids system }.each do |dir| - directory "#{new_resource.path}/shared/#{dir}" do + directory "#{new_resource.path}/#{dir}" do owner new_resource.owner group new_resource.group mode '0755' diff --git a/providers/tomcat.rb b/providers/tomcat.rb index 5f3b604..2d69058 100644 --- a/providers/tomcat.rb +++ b/providers/tomcat.rb @@ -25,7 +25,7 @@ unless new_resource.restart_command new_resource.restart_command do - run_context.resource_collection.find(:service => "tomcat").run_action(:restart) + run_context.resource_collection.find(:service => "tomcat#{node['tomcat']['base_version']}").run_action(:restart) end end @@ -45,7 +45,7 @@ link "#{node['tomcat']['context_dir']}/#{new_resource.application.name}.xml" do to "#{new_resource.application.path}/shared/#{new_resource.application.name}.xml" - notifies :restart, resources(:service => "tomcat") + notifies :restart, resources(:service => "tomcat#{node['tomcat']['base_version']}") end end