lib/supply_drop.rb in supply_drop-0.11.0 vs lib/supply_drop.rb in supply_drop-0.11.1

- old
+ new

@@ -73,31 +73,32 @@ rsync_cmd = SupplyDrop::Rsync.command( puppet_source, SupplyDrop::Rsync.remote_address(server.user || fetch(:user, ENV['USER']), server.host, puppet_destination), :delete => true, :excludes => puppet_excludes, - :world_writable => true, :ssh => { :keys => ssh_options[:keys], :config => ssh_options[:config], :port => fetch(:port, nil) } ) logger.debug rsync_cmd server.host unless system rsync_cmd end.compact raise "rsync failed on #{failed_servers.join(',')}" if failed_servers.any? end before :'puppet:update_code' do - syntax_check if puppet_syntax_check _set_threadpool_size + syntax_check if puppet_syntax_check end before 'puppet:noop' do - _lock if _should_lock? + _prep_destination + _lock end before 'puppet:apply' do - _lock if _should_lock? + _prep_destination + _lock end desc "runs puppet with --noop flag to show changes" task :noop, :except => { :nopuppet => true } do transaction do @@ -136,26 +137,29 @@ def _red_text(text) "\033[0;31m#{text}\033[0m" end + def _prep_destination + run "mkdir -p #{puppet_destination}" + run "#{sudo} chown -R $USER: #{puppet_destination}" + end + def _lock - if puppet_lock_file + if _should_lock? run <<-GETLOCK if [ ! -f #{puppet_lock_file} ]; then touch #{puppet_lock_file}; - mkdir -p #{puppet_destination}; - chmod o+w #{puppet_destination}; else stat -c "#{_red_text("Puppet in progress, #{puppet_lock_file} owned by %U since %x")}" #{puppet_lock_file} >&2; exit 1; fi GETLOCK end end def _unlock - run "rm -f #{puppet_lock_file}; true" if _should_lock? + run "#{sudo} rm -f #{puppet_lock_file}; true" if _should_lock? end def _should_lock? puppet_lock_file && !ENV['NO_PUPPET_LOCK'] end