capistrano-net_storage 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -0
- data/README.md +59 -39
- data/capistrano-net_storage.gemspec +4 -4
- data/lib/capistrano/net_storage/archiver/base.rb +8 -11
- data/lib/capistrano/net_storage/archiver/tar_gzip.rb +12 -10
- data/lib/capistrano/net_storage/archiver/zip.rb +13 -10
- data/lib/capistrano/net_storage/bundler/default.rb +55 -0
- data/lib/capistrano/net_storage/bundler/null.rb +15 -0
- data/lib/capistrano/net_storage/cleaner.rb +34 -68
- data/lib/capistrano/net_storage/config.rb +103 -95
- data/lib/capistrano/net_storage/config_uploader.rb +58 -0
- data/lib/capistrano/net_storage/plugin.rb +40 -2
- data/lib/capistrano/net_storage/scm/base.rb +6 -27
- data/lib/capistrano/net_storage/scm/git.rb +17 -15
- data/lib/capistrano/net_storage/transport/base.rb +9 -21
- data/lib/capistrano/net_storage/version.rb +1 -1
- data/lib/capistrano/net_storage.rb +35 -2
- data/lib/capistrano/tasks/net_storage.rake +38 -128
- metadata +10 -15
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -7
- data/.travis.yml +0 -13
- data/lib/capistrano/net_storage/all.rb +0 -20
- data/lib/capistrano/net_storage/base.rb +0 -18
- data/lib/capistrano/net_storage/bundler.rb +0 -70
- data/lib/capistrano/net_storage/coordinator.rb +0 -38
- data/lib/capistrano/net_storage/error.rb +0 -6
- data/lib/capistrano/net_storage/utils.rb +0 -62
@@ -1,148 +1,58 @@
|
|
1
|
-
|
2
|
-
Capistrano::NetStorage::TASK_LOADED = true
|
3
|
-
|
1
|
+
# SEE: https://github.com/capistrano/capistrano/blob/31e142d56f8d894f28404fb225dcdbe7539bda18/lib/capistrano/scm/tasks/git.rake
|
4
2
|
namespace :net_storage do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
task check: check_dependencies
|
3
|
+
desc 'Check prerequisites and prepare directories'
|
4
|
+
task :check do
|
5
|
+
Capistrano::NetStorage.transport.check
|
6
|
+
Capistrano::NetStorage.archiver.check
|
7
|
+
Capistrano::NetStorage.scm.check
|
8
|
+
Capistrano::NetStorage.bundler.check
|
9
|
+
Capistrano::NetStorage.cleaner.check
|
10
|
+
Capistrano::NetStorage.config_uploader.check
|
14
11
|
|
15
|
-
desc 'Create and deploy archives via remove storage'
|
16
|
-
task create_release: :'net_storage:check' do
|
17
12
|
config = Capistrano::NetStorage.config
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
unless skip_upload
|
26
|
-
invoke 'net_storage:upload_archive'
|
13
|
+
run_locally do
|
14
|
+
execute(:mkdir, '-p',
|
15
|
+
config.local_base_path,
|
16
|
+
config.local_mirror_path,
|
17
|
+
config.local_releases_path,
|
18
|
+
config.local_archives_path,
|
19
|
+
)
|
27
20
|
end
|
28
|
-
invoke 'net_storage:pull_deploy'
|
29
21
|
end
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
Capistrano::NetStorage.scm.
|
23
|
+
task :prepare_mirror_repository do
|
24
|
+
Capistrano::NetStorage.scm.clone
|
25
|
+
Capistrano::NetStorage.scm.update
|
26
|
+
Capistrano::NetStorage.scm.set_current_revision # :current_revision is set here, not in net_storage:set_current_revision
|
34
27
|
end
|
35
28
|
|
36
|
-
|
37
|
-
|
38
|
-
desc 'Deploy config files'
|
39
|
-
task :sync_config do
|
40
|
-
config = Capistrano::NetStorage.config
|
41
|
-
Capistrano::NetStorage.scm.sync_config
|
42
|
-
Capistrano::NetStorage.bundler.sync_config unless config.skip_bundle?
|
43
|
-
end
|
44
|
-
after 'net_storage:create_release', 'net_storage:sync_config'
|
45
|
-
|
46
|
-
desc 'Clean up old release directories on local'
|
47
|
-
task :cleanup_local_releases do
|
48
|
-
Capistrano::NetStorage.cleaner.cleanup_local_releases
|
49
|
-
end
|
50
|
-
after 'deploy:cleanup', 'net_storage:cleanup_local_releases'
|
51
|
-
|
52
|
-
desc 'Clean up old archive files on remote storage'
|
53
|
-
task :cleanup_archives_on_remote_storage do
|
54
|
-
transport = Capistrano::NetStorage.transport
|
55
|
-
next unless transport.respond_to?(:cleanup)
|
56
|
-
transport.cleanup
|
57
|
-
end
|
58
|
-
after 'deploy:cleanup', 'net_storage:cleanup_archives_on_remote_storage'
|
59
|
-
|
60
|
-
desc 'Clean up old archive files on remote servers'
|
61
|
-
task :cleanup_archives do
|
62
|
-
Capistrano::NetStorage.cleaner.cleanup_archives
|
63
|
-
end
|
64
|
-
after 'deploy:cleanup', 'net_storage:cleanup_archives'
|
65
|
-
|
66
|
-
desc 'Clean up old archive files on local'
|
67
|
-
task :cleanup_local_archives do
|
68
|
-
Capistrano::NetStorage.cleaner.cleanup_local_archives
|
69
|
-
end
|
70
|
-
after 'deploy:cleanup', 'net_storage:cleanup_local_archives'
|
71
|
-
|
72
|
-
task prepare_archive: %i(net_storage:scm:update net_storage:check:bundler) do
|
73
|
-
config = Capistrano::NetStorage.config
|
29
|
+
desc 'Prepare archive (You can hook your own preparation after this)'
|
30
|
+
task :prepare_archive do
|
74
31
|
Capistrano::NetStorage.scm.prepare_archive
|
75
|
-
Capistrano::NetStorage.bundler.install
|
32
|
+
Capistrano::NetStorage.bundler.install
|
76
33
|
end
|
77
34
|
|
78
|
-
desc 'Create
|
79
|
-
task
|
80
|
-
Capistrano::NetStorage.
|
81
|
-
end
|
35
|
+
desc 'Create and deploy archives via remove storage'
|
36
|
+
task create_release: :'net_storage:prepare_mirror_repository' do
|
37
|
+
config = Capistrano::NetStorage.config
|
82
38
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
39
|
+
if !config.reuse_archive? || !Capistrano::NetStorage.transport.archive_exists?
|
40
|
+
invoke 'net_storage:prepare_archive'
|
41
|
+
Capistrano::NetStorage.archiver.archive
|
42
|
+
Capistrano::NetStorage.transport.upload
|
43
|
+
end
|
87
44
|
|
88
|
-
desc 'Deploy via remote storage using uploaded archive'
|
89
|
-
task pull_deploy: :'net_storage:transport:find_uploaded' do
|
90
45
|
Capistrano::NetStorage.transport.download
|
91
46
|
Capistrano::NetStorage.archiver.extract
|
92
|
-
end
|
93
|
-
|
94
|
-
namespace :check do
|
95
|
-
task :archiver do
|
96
|
-
Capistrano::NetStorage.archiver.check
|
97
|
-
end
|
98
|
-
|
99
|
-
task :transport do
|
100
|
-
Capistrano::NetStorage.transport.check
|
101
|
-
end
|
102
|
-
|
103
|
-
task :bundler do
|
104
|
-
config = Capistrano::NetStorage.config
|
105
|
-
Capistrano::NetStorage.bundler.check unless config.skip_bundle?
|
106
|
-
end
|
107
47
|
|
108
|
-
|
109
|
-
Capistrano::NetStorage.scm.check
|
110
|
-
end
|
111
|
-
|
112
|
-
task :directories do
|
113
|
-
config = Capistrano::NetStorage.config
|
114
|
-
dirs = [
|
115
|
-
config.local_base_path,
|
116
|
-
config.local_mirror_path,
|
117
|
-
config.local_releases_path,
|
118
|
-
config.local_archives_path,
|
119
|
-
]
|
120
|
-
dirs << config.local_bundle_path unless config.skip_bundle?
|
121
|
-
run_locally do
|
122
|
-
dirs.each { |dir| execute :mkdir, '-p', dir }
|
123
|
-
end
|
124
|
-
end
|
48
|
+
Capistrano::NetStorage.config_uploader.upload_config_files
|
125
49
|
end
|
126
50
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
Capistrano::NetStorage.scm.update
|
134
|
-
end
|
135
|
-
|
136
|
-
task set_current_revision: :'net_storage:scm:update' do
|
137
|
-
Capistrano::NetStorage.scm.set_current_revision
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
namespace :transport do
|
142
|
-
task find_uploaded: :'net_storage:scm:set_current_revision' do
|
143
|
-
Capistrano::NetStorage.transport.find_uploaded
|
144
|
-
end
|
51
|
+
desc 'Clean up old release directories on local'
|
52
|
+
task :cleanup do
|
53
|
+
Capistrano::NetStorage.cleaner.cleanup_local_releases
|
54
|
+
Capistrano::NetStorage.cleaner.cleanup_local_archives
|
55
|
+
Capistrano::NetStorage.cleaner.cleanup_archives
|
56
|
+
Capistrano::NetStorage.transport.cleanup
|
145
57
|
end
|
146
58
|
end
|
147
|
-
|
148
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-net_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- progrhyme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: '3.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: '3.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,10 +88,8 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- ".github/PULL_REQUEST_TEMPLATE.md"
|
92
91
|
- ".gitignore"
|
93
92
|
- ".rspec"
|
94
|
-
- ".travis.yml"
|
95
93
|
- CHANGELOG.md
|
96
94
|
- Gemfile
|
97
95
|
- LICENSE.txt
|
@@ -100,21 +98,18 @@ files:
|
|
100
98
|
- capistrano-net_storage.gemspec
|
101
99
|
- lib/capistrano-net_storage.rb
|
102
100
|
- lib/capistrano/net_storage.rb
|
103
|
-
- lib/capistrano/net_storage/all.rb
|
104
101
|
- lib/capistrano/net_storage/archiver/base.rb
|
105
102
|
- lib/capistrano/net_storage/archiver/tar_gzip.rb
|
106
103
|
- lib/capistrano/net_storage/archiver/zip.rb
|
107
|
-
- lib/capistrano/net_storage/
|
108
|
-
- lib/capistrano/net_storage/bundler.rb
|
104
|
+
- lib/capistrano/net_storage/bundler/default.rb
|
105
|
+
- lib/capistrano/net_storage/bundler/null.rb
|
109
106
|
- lib/capistrano/net_storage/cleaner.rb
|
110
107
|
- lib/capistrano/net_storage/config.rb
|
111
|
-
- lib/capistrano/net_storage/
|
112
|
-
- lib/capistrano/net_storage/error.rb
|
108
|
+
- lib/capistrano/net_storage/config_uploader.rb
|
113
109
|
- lib/capistrano/net_storage/plugin.rb
|
114
110
|
- lib/capistrano/net_storage/scm/base.rb
|
115
111
|
- lib/capistrano/net_storage/scm/git.rb
|
116
112
|
- lib/capistrano/net_storage/transport/base.rb
|
117
|
-
- lib/capistrano/net_storage/utils.rb
|
118
113
|
- lib/capistrano/net_storage/version.rb
|
119
114
|
- lib/capistrano/tasks/net_storage.rake
|
120
115
|
homepage: https://github.com/DeNADev/capistrano-net_storage
|
@@ -129,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
124
|
requirements:
|
130
125
|
- - ">="
|
131
126
|
- !ruby/object:Gem::Version
|
132
|
-
version: '2.
|
127
|
+
version: '2.7'
|
133
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
129
|
requirements:
|
135
130
|
- - ">="
|
data/.travis.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.6.3
|
5
|
-
- 2.5.5
|
6
|
-
- 2.4.6
|
7
|
-
|
8
|
-
before_install: gem install bundler
|
9
|
-
install: bundle install
|
10
|
-
script: bundle exec rake spec
|
11
|
-
notifications:
|
12
|
-
slack:
|
13
|
-
secure: lJCLJetpFwFujt467h250JgTyjF+7qU04Ef6FdwOBZwvjgYmyyZMBhdbL2JOAxrQd6XCWhZy56jCXr4ZdMbMLtzL+wEkQefiOLdpV/556xXK5qmkjLyRWoYOMFEhxSTqjk8hHZVYcLO6IYmwr9CHBWaVGOydADCkR4CYyqmSHtKIbznSs9Y4qrpsf6YC9QiSxoP7d5hayvnVUI8oFvxC8DfPuwrmWoO4WyVTJy2ODg/r/ZNGJCMzW3pvnXGK5oZqgwArlGIV7l3tOX2l24QilkhxhuX7QRCikYoGiIdXqkXdf1S/piaflFGXJ1C2PN5aWEv1/8EYcm7RgPm8I9Pol+7zkpUFUiSj3FDLc/TZZKP7OwPCpXOXZkDTLn0+96H5oWUR+2xwTwETQpW8Qz6ZMiu4EKAiAeU99YgSZOgc3fmonvsQREFwTV1n9AHPFsTHv8f3bzC8gUm3n7PIZX4/vR7Aa+vTVZ1QGW9T7OuWThdCMVVB7L7Q/5pRaE+gFLsN9MQBfbZ5uOOXYHd+yh9rC5qi/wRXPxQ4w1F8R+iKIhF32nUF96jwwCkd7O/LZKlmFRT43App6sfmQIAdPp7Oy/BZZD34u0k5aOciZ59h10+BHmA1E0kphXfbYcbXd53MUCEiYc4HC2xtC5yT+ko+PQ2T37VkkneZIIhjRf+WzXQ=
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'capistrano/net_storage/base'
|
2
|
-
require 'capistrano/net_storage/error'
|
3
|
-
require 'capistrano/net_storage/config'
|
4
|
-
require 'capistrano/net_storage/coordinator'
|
5
|
-
require 'capistrano/net_storage/utils'
|
6
|
-
require 'capistrano/net_storage/bundler'
|
7
|
-
require 'capistrano/net_storage/cleaner'
|
8
|
-
require 'capistrano/net_storage/archiver/zip'
|
9
|
-
require 'capistrano/net_storage/archiver/tar_gzip'
|
10
|
-
require 'capistrano/net_storage/scm/git'
|
11
|
-
require 'capistrano/net_storage/version'
|
12
|
-
|
13
|
-
# See capistrano/net_storage/base.rb
|
14
|
-
Capistrano::NetStorage.setup! do
|
15
|
-
config = Capistrano::NetStorage::Config.new
|
16
|
-
{
|
17
|
-
config: config,
|
18
|
-
coordinator: Capistrano::NetStorage::Coordinator.new(config),
|
19
|
-
}
|
20
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module Capistrano
|
4
|
-
module NetStorage
|
5
|
-
class << self
|
6
|
-
attr_reader :config, :coordinator
|
7
|
-
|
8
|
-
extend Forwardable
|
9
|
-
def_delegators :coordinator, :archiver, :scm, :cleaner, :bundler, :transport
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.setup!(params = nil)
|
13
|
-
params ||= yield
|
14
|
-
@config = params[:config]
|
15
|
-
@coordinator = params[:coordinator]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'capistrano/net_storage/utils'
|
3
|
-
|
4
|
-
module Capistrano
|
5
|
-
module NetStorage
|
6
|
-
class Bundler
|
7
|
-
include Capistrano::NetStorage::Utils
|
8
|
-
|
9
|
-
def check
|
10
|
-
run_locally do
|
11
|
-
execute :which, 'bundle'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# Do bundle install locally. Installed gems are to be included to the release.
|
16
|
-
def install
|
17
|
-
c = config
|
18
|
-
run_locally do
|
19
|
-
local_release_bundle_path = c.local_release_path.join('vendor', 'bundle')
|
20
|
-
execute :mkdir, '-p', local_release_bundle_path
|
21
|
-
execute :mkdir, '-p', "#{c.local_release_path}/.bundle"
|
22
|
-
# Copy shared gems to release bundle path beforehand to reuse installed previously
|
23
|
-
execute :rsync, '-a', "#{c.local_bundle_path}/", "#{local_release_bundle_path}/"
|
24
|
-
|
25
|
-
within c.local_release_path do
|
26
|
-
::Bundler.with_clean_env do
|
27
|
-
install_options = %W(
|
28
|
-
--gemfile #{c.local_release_path}/Gemfile --deployment --quiet
|
29
|
-
--path #{local_release_bundle_path} --without development test
|
30
|
-
)
|
31
|
-
execute :bundle, 'install', *install_options
|
32
|
-
execute :bundle, 'clean'
|
33
|
-
# Sync installed gems to shared directory to reuse them next time
|
34
|
-
rsync_options = %W(-a --delete #{local_release_bundle_path}/ #{c.local_bundle_path}/)
|
35
|
-
execute :rsync, *rsync_options
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Create +.bundle/config+ at release path on remote servers
|
42
|
-
def sync_config
|
43
|
-
c = config
|
44
|
-
|
45
|
-
on c.servers, in: :groups, limit: c.max_parallels do
|
46
|
-
within release_path do
|
47
|
-
execute :mkdir, '-p', '.bundle'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
run_locally do
|
52
|
-
execute :mkdir, '-p', "#{c.local_base_path}/.bundle"
|
53
|
-
end
|
54
|
-
bundle_config_path = "#{c.local_base_path}/.bundle/config"
|
55
|
-
File.open(bundle_config_path, 'w') do |file|
|
56
|
-
file.print(<<-EOS)
|
57
|
-
---
|
58
|
-
BUNDLE_FROZEN: "1"
|
59
|
-
BUNDLE_PATH: "#{release_path.join('vendor', 'bundle')}"
|
60
|
-
BUNDLE_WITHOUT: "development:test"
|
61
|
-
BUNDLE_DISABLE_SHARED_GEMS: "true"
|
62
|
-
BUNDLE_BIN: "#{release_path.join('bin')}"
|
63
|
-
EOS
|
64
|
-
end
|
65
|
-
|
66
|
-
upload_files([bundle_config_path], release_path.join('.bundle'))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Capistrano
|
2
|
-
module NetStorage
|
3
|
-
class Coordinator
|
4
|
-
attr_reader :config
|
5
|
-
|
6
|
-
def initialize(config)
|
7
|
-
@config = config
|
8
|
-
end
|
9
|
-
|
10
|
-
def archiver
|
11
|
-
load_executor(:archiver)
|
12
|
-
end
|
13
|
-
|
14
|
-
def transport
|
15
|
-
load_executor(:transport)
|
16
|
-
end
|
17
|
-
|
18
|
-
def cleaner
|
19
|
-
load_executor(:cleaner)
|
20
|
-
end
|
21
|
-
|
22
|
-
def bundler
|
23
|
-
load_executor(:bundler)
|
24
|
-
end
|
25
|
-
|
26
|
-
def scm
|
27
|
-
load_executor(:scm)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def load_executor(type)
|
33
|
-
@executors ||= {}
|
34
|
-
@executors[type] ||= config.executor_class(type).new
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'capistrano/net_storage/base'
|
2
|
-
|
3
|
-
module Capistrano
|
4
|
-
module NetStorage
|
5
|
-
# Common utility methods
|
6
|
-
module Utils
|
7
|
-
private
|
8
|
-
|
9
|
-
# @see lib/capistrano/net_storage/base.rb
|
10
|
-
def config
|
11
|
-
Capistrano::NetStorage.config
|
12
|
-
end
|
13
|
-
|
14
|
-
# @param dest_dir [String, Pathname] Destination directory on remote to copy local files into
|
15
|
-
def upload_files(files, dest_dir)
|
16
|
-
c = config
|
17
|
-
hosts = ::Capistrano::Configuration.env.filter(c.servers)
|
18
|
-
|
19
|
-
# FIXME: This is a very workaround to architectural issue. Do not copy.
|
20
|
-
build_rsh_option = -> (host) {
|
21
|
-
build_ssh_command(host)
|
22
|
-
}
|
23
|
-
|
24
|
-
on hosts, in: :groups, limit: c.max_parallels do |host|
|
25
|
-
if c.upload_files_by_rsync?
|
26
|
-
rsh_option = build_rsh_option.call(host)
|
27
|
-
run_locally do
|
28
|
-
execute :rsync, "-az --rsh='#{rsh_option}' #{files.join(' ')} #{host.hostname}:#{dest_dir}"
|
29
|
-
end
|
30
|
-
else
|
31
|
-
files.each do |src|
|
32
|
-
upload! src, dest_dir
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Build ssh command with options for rsync
|
39
|
-
def build_ssh_command(host)
|
40
|
-
user_opt = ''
|
41
|
-
key_opt = ''
|
42
|
-
port_opt = ''
|
43
|
-
ssh_options = config.rsync_options
|
44
|
-
|
45
|
-
if user = host.user || ssh_options[:user]
|
46
|
-
user_opt = " -l #{user}"
|
47
|
-
end
|
48
|
-
|
49
|
-
if keys = (host.keys.empty? ? ssh_options[:keys] : host.keys)
|
50
|
-
keys = keys.is_a?(Array) ? keys : [keys]
|
51
|
-
key_opt = keys.map { |key| " -i #{key}" }.join('')
|
52
|
-
end
|
53
|
-
|
54
|
-
if port = host.port || ssh_options[:port]
|
55
|
-
port_opt = " -p #{port}"
|
56
|
-
end
|
57
|
-
|
58
|
-
"ssh#{user_opt}#{key_opt}#{port_opt}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|