capistrano-stretcher 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/capistrano-stretcher.gemspec +3 -3
- data/lib/capistrano/tasks/stretcher.rake +38 -3
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7ba1db01edfbfc1ff473bad8a02196740f3f92c
|
4
|
+
data.tar.gz: 22ded6adc6e0252c3ca601c9d7b9a7e2be1f08a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 194e97730f312140b0ddaf183c284a34e027137eaefbbac108548bcc61556e4208b4a10992ab884626a5ecdee94cbf514d5cd1ac7eec9c3668aef4c94ba3e002
|
7
|
+
data.tar.gz: efbcee6ae550cf5fe3fc2380a1839fad3c5c4ff5859c723a60dea07cb433b4387541e330f4c11def4f9a236b665fc36f8cfe2f3379fdb891b69c7cbe2dd10cfd
|
data/README.md
CHANGED
@@ -30,9 +30,12 @@ capistrano-stretcher requires target server for building to application assets.
|
|
30
30
|
* openssl
|
31
31
|
* aws-cli
|
32
32
|
* consul
|
33
|
+
* pv
|
33
34
|
|
34
35
|
target server builds assets, uploads assets to AWS S3 and invokes `consul event` automatically. So target server can access AWS s3 via aws-cli and join your deployment consul cluster.
|
35
36
|
|
37
|
+
If you want to use non-s3 (e.g. private DC), upload assets to your server with rsync and download from http(s).
|
38
|
+
|
36
39
|
## Usage
|
37
40
|
|
38
41
|
You need to add `require "capistrano/stretcher"` to Capfile and add `config/deploy.rb` following variables:
|
@@ -54,6 +57,13 @@ set :stretcher_src, "s3://your-deployment-bucket/assets/rails-application-#{env.
|
|
54
57
|
set :manifest_path, "s3://your-deployment-bucket/manifests/"
|
55
58
|
# Optional, if you want to use mv
|
56
59
|
set :stretcher_sync_strategy, "mv"
|
60
|
+
|
61
|
+
# Optinal, if you want to http(s) in stretcher_src, manifest_path
|
62
|
+
set :rsync_ssh_option, "-p 22"
|
63
|
+
set :rsync_ssh_user, "MY_USER" # if undefined, use current user on build server
|
64
|
+
set :rsync_host, "xxx.xxx.xxx.xxx"
|
65
|
+
set :rsync_stretcher_src_path, "/var/www/resource/assets/rails-application-#{env.now}.tgz"
|
66
|
+
set :rsync_manifest_path, "/var/www/resource/manifests"
|
57
67
|
```
|
58
68
|
|
59
69
|
and write hooks for stretcher to `config/stretcher.yml.erb`
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "capistrano-stretcher"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.4.0"
|
8
8
|
spec.authors = ["SHIBATA Hiroshi", "Uchio Kondo"]
|
9
9
|
spec.email = ["hsbt@ruby-lang.org", "udzura@udzura.jp"]
|
10
10
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency 'capistrano', '>= 3'
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
25
|
end
|
@@ -39,6 +39,22 @@ namespace :stretcher do
|
|
39
39
|
roles(fetch(:consul_roles, [:consul]))
|
40
40
|
end
|
41
41
|
|
42
|
+
# upload to s3
|
43
|
+
def upload_s3(local_src_path, remote_dst_path)
|
44
|
+
execute :aws, :s3, :cp, local_src_path, remote_dst_path
|
45
|
+
end
|
46
|
+
|
47
|
+
# upload to resource server with rsync
|
48
|
+
def upload_resource(local_src_path, remote_dst_path)
|
49
|
+
rsync_ssh_command = "ssh"
|
50
|
+
rsync_ssh_command << " " + fetch(:rsync_ssh_option) if fetch(:rsync_ssh_option)
|
51
|
+
rsync_ssh_user = fetch(:rsync_ssh_user) { capture(:whoami).strip }
|
52
|
+
|
53
|
+
execute :rsync, "-ave", %Q("#{rsync_ssh_command}"),
|
54
|
+
local_src_path,
|
55
|
+
"#{rsync_ssh_user}@#{fetch(:rsync_host)}:#{remote_dst_path}"
|
56
|
+
end
|
57
|
+
|
42
58
|
task :mark_deploying do
|
43
59
|
set :deploying, true
|
44
60
|
end
|
@@ -100,7 +116,15 @@ namespace :stretcher do
|
|
100
116
|
task :upload_tarball do
|
101
117
|
on application_builder_roles do
|
102
118
|
as 'root' do
|
103
|
-
|
119
|
+
local_tarball_file = "#{local_tarball_path}/current/#{fetch(:local_tarball_name)}"
|
120
|
+
|
121
|
+
if fetch(:stretcher_src).start_with?("s3://")
|
122
|
+
# upload to s3
|
123
|
+
upload_s3(local_tarball_file, fetch(:stretcher_src))
|
124
|
+
else
|
125
|
+
# upload to resource server with rsync
|
126
|
+
upload_resource(local_tarball_file, fetch(:rsync_stretcher_src_path))
|
127
|
+
end
|
104
128
|
end
|
105
129
|
end
|
106
130
|
end
|
@@ -120,8 +144,19 @@ namespace :stretcher do
|
|
120
144
|
t.write yml
|
121
145
|
t.path
|
122
146
|
end
|
123
|
-
|
124
|
-
|
147
|
+
|
148
|
+
local_manifest_file = "#{local_tarball_path}/current/manifest_#{role}_#{fetch(:stage)}.yml"
|
149
|
+
|
150
|
+
upload! tempfile_path, local_manifest_file
|
151
|
+
|
152
|
+
if fetch(:manifest_path).start_with?("s3://")
|
153
|
+
# upload to s3
|
154
|
+
upload_s3(local_manifest_file, "#{fetch(:manifest_path)}/manifest_#{role}_#{fetch(:stage)}.yml")
|
155
|
+
else
|
156
|
+
# upload to resource server with rsync
|
157
|
+
execute :chmod, "644", local_manifest_file
|
158
|
+
upload_resource(local_manifest_file, "#{fetch(:rsync_manifest_path)}/manifest_#{role}_#{fetch(:stage)}.yml")
|
159
|
+
end
|
125
160
|
end
|
126
161
|
end
|
127
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-stretcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIBATA Hiroshi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -29,30 +29,30 @@ dependencies:
|
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: minitest
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.4
|
110
|
+
rubygems_version: 2.6.4
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: capistrano task for stretcher.
|