capistrano-opscomplete 0.6.1 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -2
- data/Gemfile.lock +3 -3
- data/README.md +25 -1
- data/lib/capistrano-opscomplete.rb +0 -0
- data/lib/capistrano/dsl/opscomplete.rb +36 -4
- data/lib/capistrano/opscomplete.rb +2 -1
- data/lib/capistrano/opscomplete/hooks.rb +1 -0
- data/lib/capistrano/opscomplete/nodejs.rake +53 -0
- data/lib/capistrano/opscomplete/ruby.rake +41 -1
- data/lib/capistrano/opscomplete/supervisor.rake +3 -3
- data/lib/capistrano/opscomplete/version.rb +1 -1
- metadata +6 -4
- data/lib/capistrano/opscomplete/deploy.rake +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed8a513cbd0320e4dcc3e13764c70c5dbb8752a489f3a26b1d0c8d1aa480d142
|
4
|
+
data.tar.gz: fd3b323ce020ed6e69da74094ac4fe8feb8d88531ad7f03475c99054f7cf238c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2504a842b191d5384183c14b90f74cb762eb530bd2ed36541486420d615c1ee2c347fc88c2896ffe981741a21d4c1e72c58bbecbc3fbd514bf0d280831d0340
|
7
|
+
data.tar.gz: 5d3aa33cadda83cc57c45248b46c0b0e7f96856aa8c51d8f3dce79cc93b7a5c7efa5e290499482cdafabc6f8ae6e6cdddc4518d1a26f03230f27e1544282cc65
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,41 @@
|
|
1
|
-
##
|
1
|
+
## [0.6.6] - 2020-12-08
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
- Fix the error `undefined method 'after' for main:Object (NoMethodError)` when starting the rails application with capistrano-opscomplete required
|
5
|
+
|
6
|
+
## [0.6.5] - 2020-11-20
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- Correct warning message for `opscomplete:ruby:broken_gems_warning`
|
10
|
+
|
11
|
+
## [0.6.4] - 2020-11-19
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- You can now manage the Node.js version which needs to be installed
|
15
|
+
- Add two new capistrano tasks (`opscomplete:ruby:broken_gems_warning`, `opscomplete:ruby:reset`) which help to mitigate problems when a deployment fails (described in: [#19](https://github.com/makandra/capistrano-opscomplete/issues/19))
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- Added missing namespace for code example
|
19
|
+
|
20
|
+
## [0.6.3] - 2020-07-23
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
- regression after ([#18](https://github.com/makandra/capistrano-opscomplete/issues/18)) was merged
|
24
|
+
|
25
|
+
## [0.6.2] - 2020-07-23
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
- rbenv-build changed behaviour of `--list` ([#20](https://github.com/makandra/capistrano-opscomplete/issues/20))
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
- Bumped rack dependency from 2.1.1 to 2.2.3
|
32
|
+
|
33
|
+
## [0.6.1] - 2020-04-16
|
34
|
+
### Added
|
35
|
+
- Use Ruby 2.6 for development
|
2
36
|
|
3
37
|
### Changed
|
4
|
-
-
|
38
|
+
- Add rake as a runtime dependency
|
5
39
|
|
6
40
|
## [0.6.0] - 2020-01-13
|
7
41
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capistrano-opscomplete (0.6.
|
4
|
+
capistrano-opscomplete (0.6.6)
|
5
5
|
capistrano (>= 3.0, < 4.0.0)
|
6
6
|
rake
|
7
7
|
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
rake (>= 10.0.0)
|
18
18
|
sshkit (>= 1.9.0)
|
19
19
|
concurrent-ruby (1.1.6)
|
20
|
-
i18n (1.8.
|
20
|
+
i18n (1.8.4)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
22
|
jaro_winkler (1.5.4)
|
23
23
|
makandra-rubocop (4.2.0)
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
parallel (1.19.1)
|
30
30
|
parser (2.7.0.2)
|
31
31
|
ast (~> 2.4.0)
|
32
|
-
rack (2.
|
32
|
+
rack (2.2.3)
|
33
33
|
rainbow (3.0.0)
|
34
34
|
rake (13.0.1)
|
35
35
|
rubocop (0.76.0)
|
data/README.md
CHANGED
@@ -36,7 +36,13 @@ An example configuration could look like this:
|
|
36
36
|
after 'deploy:updating', 'opscomplete:ruby:ensure'
|
37
37
|
```
|
38
38
|
|
39
|
-
|
39
|
+
If you want to handle the ruby version for rollbacks too, you should add:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
after 'deploy:reverting', 'opscomplete:ruby:ensure'
|
43
|
+
```
|
44
|
+
|
45
|
+
And in case you enabled [`Procfile support`](https://makandracards.com/opscomplete/67829-procfile-support) you can use the following tasks:
|
40
46
|
|
41
47
|
opscomplete:supervisor:gen_config
|
42
48
|
opscomplete:supervisor:restart_procs
|
@@ -151,6 +157,24 @@ There are many hooks available in the [default deploy flow](https://capistranorb
|
|
151
157
|
after 'deploy:updating', 'opscomplete:ruby:ensure'
|
152
158
|
```
|
153
159
|
|
160
|
+
## Managing your nodejs version with `capistrano-opscomplete`
|
161
|
+
|
162
|
+
You can manage NodeJS also with `capistrano-opscomplete`. It will check the `.nvmrc`, `.node-version` and `.tool-versions` in the release direcotry (in this order) or you can configure it with `:opscomplete_nodejs_version` in your capistrano configuration.
|
163
|
+
|
164
|
+
Include the gem in your applications Gemfile:
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
gem 'capistrano-opscomplete'
|
168
|
+
```
|
169
|
+
|
170
|
+
Now, add some [hooks](#using-capistrano-hooks) in your capistrano configuration (e.g. `deploy.rb`).
|
171
|
+
An example configuration could look like this:
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
# After unpacking your release, before bundling, compiling assets, ...
|
175
|
+
after 'deploy:updating', 'opscomplete:nodejs:ensure'
|
176
|
+
```
|
177
|
+
|
154
178
|
## Contributing
|
155
179
|
|
156
180
|
Bug reports and pull requests are welcome. Don't hesitate to [open a new issue](https://github.com/makandra/capistrano-opscomplete/issues/new).
|
File without changes
|
@@ -24,17 +24,17 @@ module Capistrano
|
|
24
24
|
# 1) Get version from capistrano configuration (highest precedence, 'override')
|
25
25
|
if fetch(:opscomplete_ruby_version)
|
26
26
|
debug("Using version from :opscomplete_ruby_version setting: #{fetch(:opscomplete_ruby_version)}.")
|
27
|
-
|
27
|
+
fetch(:opscomplete_ruby_version)
|
28
28
|
|
29
29
|
# 2) Get version from .ruby-version in release dir (after deploy:updating, before deploy:updated)
|
30
30
|
elsif test("[ -f #{release_ruby_version_file_path} ]")
|
31
31
|
debug("Using version from server's release_dir/.ruby-version file: #{capture(:cat, release_ruby_version_file_path)}")
|
32
|
-
|
32
|
+
capture(:cat, release_ruby_version_file_path)
|
33
33
|
|
34
34
|
# 3) Get version from local checkout/cwd
|
35
35
|
elsif File.readable?('.ruby-version')
|
36
36
|
debug("Using version from local (cwd) .ruby-version file: #{File.read('.ruby-version').strip}")
|
37
|
-
|
37
|
+
File.read('.ruby-version').strip
|
38
38
|
|
39
39
|
# FAIL: We have no idea which version to use
|
40
40
|
else
|
@@ -65,7 +65,7 @@ module Capistrano
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def rbenv_installable_rubies
|
68
|
-
rbenv_installable_rubies = capture(:rbenv, :install, '--list').split("\n")
|
68
|
+
rbenv_installable_rubies = capture(:rbenv, :install, '--list-all').split("\n")
|
69
69
|
rbenv_installable_rubies.map!(&:strip)
|
70
70
|
rbenv_installable_rubies.delete('Available version:')
|
71
71
|
rbenv_installable_rubies
|
@@ -108,6 +108,38 @@ module Capistrano
|
|
108
108
|
def rubygems_install(version)
|
109
109
|
rbenv_exec("gem update --no-document --system '#{version}'")
|
110
110
|
end
|
111
|
+
|
112
|
+
def managed_nodejs?
|
113
|
+
test("[ -f ${HOME}/.nodejs_managed_by_makandra ]")
|
114
|
+
end
|
115
|
+
|
116
|
+
def app_nodejs_version
|
117
|
+
|
118
|
+
# 1) Get version from capistrano configuration (highest precedence, 'override')
|
119
|
+
if fetch(:opscomplete_nodejs_version)
|
120
|
+
debug("Using version from :opscomplete_nodejs_version setting: #{fetch(:opscomplete_nodejs_version)}.")
|
121
|
+
fetch(:opscomplete_nodejs_version)
|
122
|
+
|
123
|
+
# 2) Get version from version file in release dir (after deploy:updating, before deploy:updated)
|
124
|
+
elsif capture(:nodejs_get_version, release_path)
|
125
|
+
debug("Using version from server's release_dir/.nvmrc, .node-version or .tool-versions file: #{capture(:nodejs_get_version, release_path)}")
|
126
|
+
capture(:nodejs_get_version, release_path)
|
127
|
+
|
128
|
+
else
|
129
|
+
raise Capistrano::ValidationError, 'Could not find application\'s Node.js version. Consider setting opscomplete_ruby_version.'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def nodejs_installable_versions
|
134
|
+
nodejs_installable_versions = capture(:nodejs_installable_versions).split("\n")
|
135
|
+
nodejs_installable_versions.map!(&:strip)
|
136
|
+
nodejs_installable_versions
|
137
|
+
end
|
138
|
+
|
139
|
+
def nodejs_installed_versions
|
140
|
+
nodejs_installed_versions = capture(:nodejs_installed_versions).split("\n")
|
141
|
+
nodejs_installed_versions.map!(&:strip)
|
142
|
+
end
|
111
143
|
end
|
112
144
|
end
|
113
145
|
end
|
@@ -4,5 +4,6 @@ require 'capistrano/opscomplete/version'
|
|
4
4
|
require 'rake'
|
5
5
|
|
6
6
|
load File.expand_path('opscomplete/ruby.rake', __dir__)
|
7
|
+
load File.expand_path('opscomplete/nodejs.rake', __dir__)
|
7
8
|
load File.expand_path('opscomplete/supervisor.rake', __dir__)
|
8
|
-
load File.expand_path('opscomplete/
|
9
|
+
load File.expand_path('../opscomplete/hooks.rb', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
after 'deploy:failed', 'opscomplete:ruby:broken_gems_warning'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# vim: filetype=ruby
|
2
|
+
require 'capistrano/dsl/opscomplete'
|
3
|
+
|
4
|
+
namespace :opscomplete do
|
5
|
+
include Capistrano::DSL::Opscomplete
|
6
|
+
# desc 'Validate opscomplete specific configuration'
|
7
|
+
task :validate do
|
8
|
+
invoke('opscomplete:nodejs:check')
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :nodejs do
|
12
|
+
desc 'Check if nodejs version is set according to application\'s .node-version or .nvmrc (in this order).'
|
13
|
+
task :check do
|
14
|
+
on roles fetch(:nodejs_roles, :all) do |host|
|
15
|
+
warn("#{host}: Managed Node.js environment! Won't do any changes to nodejs version.") if managed_nodejs?
|
16
|
+
unless capture(:nodejs_current_version) == app_nodejs_version
|
17
|
+
raise Capistrano::ValidationError,
|
18
|
+
"#{host}: Node.js version is not set according to application\'s .node-version or .nvmrc file. Use cap opscomplete:nodejs:ensure."
|
19
|
+
end
|
20
|
+
info("#{host}: Node.js #{app_nodejs_version} is installed.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Update Node.js version management tool'
|
25
|
+
task :update_nodejs_build do
|
26
|
+
on roles fetch(:nodejs_roles, :all) do
|
27
|
+
execute :nodejs_update_management_tool
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Install and configure NodeJS according to applications .nvmrc, .node-version or .tool-versions.'
|
32
|
+
task :ensure do
|
33
|
+
invoke('opscomplete:nodejs:update_nodejs_build')
|
34
|
+
on roles fetch(:nodejs_roles, :all) do |host|
|
35
|
+
if managed_nodejs?
|
36
|
+
raise Capistrano::ValidationError, "#{host}: Managed Node.js environment! Won't do any changes to Node.js version."
|
37
|
+
end
|
38
|
+
if nodejs_installed_versions.include?(app_nodejs_version)
|
39
|
+
info("#{host}: Node.js #{app_nodejs_version} is installed.")
|
40
|
+
elsif nodejs_installable_versions.include?(app_nodejs_version)
|
41
|
+
info("#{host}: Configured Node.js version is not installed, but available for installation.")
|
42
|
+
with tmpdir: fetch(:tmp_dir) do
|
43
|
+
execute(:nodejs_install_version, "'#{app_nodejs_version}'")
|
44
|
+
end
|
45
|
+
else
|
46
|
+
raise Capistrano::ValidationError,
|
47
|
+
"#{host}: Configured Node.js version is neither installed nor installable."
|
48
|
+
end
|
49
|
+
execute(:nodejs_set_version, "'#{app_nodejs_version}'")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -106,12 +106,52 @@ namespace :opscomplete do
|
|
106
106
|
raise Capistrano::ValidationError,
|
107
107
|
"#{host}: Configured Ruby version is neither installed nor installable using ruby-install."
|
108
108
|
end
|
109
|
-
|
109
|
+
unless capture(:rbenv, :global) == app_ruby_version
|
110
|
+
set :ruby_modified, true
|
111
|
+
execute(:rbenv, :global, "'#{app_ruby_version}'")
|
112
|
+
end
|
110
113
|
end
|
111
114
|
invoke('opscomplete:ruby:install_rubygems')
|
112
115
|
invoke('opscomplete:ruby:install_bundler')
|
113
116
|
invoke('opscomplete:ruby:install_geordi')
|
114
117
|
invoke('opscomplete:ruby:rehash') if fetch(:rbenv_needs_rehash, false)
|
115
118
|
end
|
119
|
+
|
120
|
+
desc 'resets the global ruby version and gems to Gemfile and .ruby-version in current_path.'
|
121
|
+
task :reset do
|
122
|
+
on roles fetch(:rbenv_roles, :all) do |host|
|
123
|
+
within current_path do
|
124
|
+
current_ruby_version_file_path = current_path.join('.ruby-version').to_s
|
125
|
+
if test("[ -f #{current_ruby_version_file_path} ]")
|
126
|
+
execute(:rbenv, :global, capture(:cat, current_ruby_version_file_path))
|
127
|
+
else
|
128
|
+
raise Capistrano::ValidationError,
|
129
|
+
"#{host}: Missing .ruby-version in #{current_path}. Won't set a new global version."
|
130
|
+
end
|
131
|
+
if test("[ -f '#{current_path}/.bundle/config' ]")
|
132
|
+
debug("#{host}: Found #{current_path}/.bundle/config, running bundle pristine.")
|
133
|
+
set :bundle_gemfile, -> { current_path.join('Gemfile') }
|
134
|
+
execute(:bundle, :pristine)
|
135
|
+
else
|
136
|
+
raise Capistrano::ValidationError,
|
137
|
+
"Unable to find #{current_path}/.bundle/config, won't run bundle pristine."
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
desc 'Set the old ruby version before the change and invoke bundle pristine.'
|
144
|
+
task :broken_gems_warning do
|
145
|
+
on roles fetch(:rbenv_roles, :all) do |host|
|
146
|
+
if fetch(:ruby_modified, false)
|
147
|
+
warn("Deploy failed and the ruby version has been modified in this deploy.")
|
148
|
+
warn("If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.")
|
149
|
+
warn("If your deploy failed before deploy:symlink:release you may run bundle exec `cap #{fetch(:stage)} opscomplete:ruby:reset`.")
|
150
|
+
warn("Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions")
|
151
|
+
else
|
152
|
+
debug("#{host}: Ruby not modified in current deploy.")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
116
156
|
end
|
117
157
|
end
|
@@ -27,7 +27,7 @@ namespace :opscomplete do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# Can be used for example to quiet sidekiq with a task like this:
|
32
32
|
#
|
33
33
|
# namespace :sidekiq do
|
@@ -36,12 +36,12 @@ namespace :opscomplete do
|
|
36
36
|
# on roles :cron do
|
37
37
|
# # The TSTP signal tells sidekiq to quiet all workers.
|
38
38
|
# # see: https://github.com/mperham/sidekiq/wiki/Signals#tstp
|
39
|
-
# invoke('supervisor:signal_procs', 'TSTP', 'sidekiq')
|
39
|
+
# invoke('opscomplete:supervisor:signal_procs', 'TSTP', 'sidekiq')
|
40
40
|
# end
|
41
41
|
# end
|
42
42
|
# end
|
43
43
|
desc 'Sends the signal (e.g. USR1 or TSTP) to all programs or if specified to program_name.'
|
44
|
-
task :signal_procs, :signal, :program_name do |
|
44
|
+
task :signal_procs, :signal, :program_name do |_task_name, args|
|
45
45
|
signal = args.fetch(:signal)
|
46
46
|
program_name = args.fetch(:program_name, nil)
|
47
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-opscomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makandra Operations
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: makandra-rubocop
|
@@ -89,9 +89,11 @@ files:
|
|
89
89
|
- bin/console
|
90
90
|
- bin/setup
|
91
91
|
- capistrano-opscomplete.gemspec
|
92
|
+
- lib/capistrano-opscomplete.rb
|
92
93
|
- lib/capistrano/dsl/opscomplete.rb
|
93
94
|
- lib/capistrano/opscomplete.rb
|
94
|
-
- lib/capistrano/opscomplete/
|
95
|
+
- lib/capistrano/opscomplete/hooks.rb
|
96
|
+
- lib/capistrano/opscomplete/nodejs.rake
|
95
97
|
- lib/capistrano/opscomplete/ruby.rake
|
96
98
|
- lib/capistrano/opscomplete/supervisor.rake
|
97
99
|
- lib/capistrano/opscomplete/version.rb
|
@@ -118,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
120
|
- !ruby/object:Gem::Version
|
119
121
|
version: 2.0.1
|
120
122
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.0.3
|
122
124
|
signing_key:
|
123
125
|
specification_version: 4
|
124
126
|
summary: Capistrano tasks for easy deployment to a makandra opscomplete environment.
|