capistrano-opscomplete 0.6.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/capistrano/dsl/opscomplete.rb +14 -42
- data/lib/capistrano/opscomplete/ruby.rake +30 -41
- data/lib/capistrano/opscomplete/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7bda13c0f33ab7e11818d801b18587bb9cd5754f114b757627296d4cb1fc338
|
4
|
+
data.tar.gz: 7587402cf62a88b9b7980ec1567f60552fa6fa8d8f1eb10d811c123175323bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76e8a0d39c56bbc84fa91d4fc52fb1c22106c6afe19f47e0dff2a27fbd81ce0c2cf76cc7d0b2d90b6aa270d71fa9d5de02a076291883bc7bbc2c1c59a1e864cb
|
7
|
+
data.tar.gz: a481d59f2a8e9cf719ec0e6120eebf9672c0a765bfe69ef253c262879c0d0d0f5874ad0a3508b7c7e3b93173ec8ae054090b55384f640e82773d86fb5779e2fa
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -111,11 +111,11 @@ More specifically this task will:
|
|
111
111
|
1) The value of `:opscomplete_ruby_version` from your capistrano config. Leave this empty unless you want to override the desired version.
|
112
112
|
2) A file in the `release_path` on the server (e.g. `/var/www/staging.myapp.biz/releases/20180523234205/.ruby-version`)
|
113
113
|
3) A file in the current working directory of your local checkout (e.g. `/home/user/code/myapp/.ruby-version`)
|
114
|
-
- If the desired version is not installed, it checks if it can be installed
|
115
|
-
- Check if
|
114
|
+
- If the desired version is not installed, it checks if it can be installed and installs it.
|
115
|
+
- Check if the global version is set according to application's `.ruby-version` file. Change it if required.
|
116
116
|
- Install `bundler`. It is tried to determine the version that was used to create the `Gemfile.lock` (`BUNDLED WITH`) if it is present.
|
117
117
|
- Install `geordi` gem if required.
|
118
|
-
-
|
118
|
+
- Rehash the shims if required.
|
119
119
|
|
120
120
|
**Note:** If, for any reason, no `.ruby-version` file can be found in your release or current working directory, you may set the following option in `deploy.rb`:
|
121
121
|
|
@@ -3,19 +3,7 @@ module Capistrano
|
|
3
3
|
# A whole capistrano/rake namespace, for grouping our helpers and tasks
|
4
4
|
module Opscomplete
|
5
5
|
def managed_ruby?
|
6
|
-
test(
|
7
|
-
end
|
8
|
-
|
9
|
-
def rbenv_ruby_build_path
|
10
|
-
"#{rbenv_root_path}/plugins/ruby-build"
|
11
|
-
end
|
12
|
-
|
13
|
-
def rbenv_repo_url
|
14
|
-
'https://github.com/rbenv/rbenv.git'
|
15
|
-
end
|
16
|
-
|
17
|
-
def ruby_build_repo_url
|
18
|
-
'https://github.com/rbenv/ruby-build.git'
|
6
|
+
test(:ruby_update_management_tool, 'managed')
|
19
7
|
end
|
20
8
|
|
21
9
|
def app_ruby_version
|
@@ -64,51 +52,35 @@ module Capistrano
|
|
64
52
|
end
|
65
53
|
end
|
66
54
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rbenv_installable_rubies
|
72
|
-
end
|
73
|
-
|
74
|
-
def rbenv_root_path
|
75
|
-
capture(:rbenv, :root)
|
55
|
+
def ruby_installable_versions
|
56
|
+
ruby_installable_versions = capture(:ruby_installable_versions).split("\n")
|
57
|
+
ruby_installable_versions.map!(&:strip)
|
58
|
+
ruby_installable_versions
|
76
59
|
end
|
77
60
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
warn("Could not look up installed versions from missing '.rbenv/versions' directory. This is probably the first ruby install for this rbenv.")
|
84
|
-
[]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def rbenv_exec(*args)
|
89
|
-
execute(:rbenv, :exec, *args)
|
61
|
+
def ruby_installed_versions
|
62
|
+
ruby_installed_versions = capture(:ruby_installed_versions).split("\n")
|
63
|
+
ruby_installed_versions.map!(&:strip)
|
64
|
+
warn('Could not look up installed versions. This is probably the first ruby install.') if ruby_installed_versions.empty?
|
65
|
+
ruby_installed_versions
|
90
66
|
end
|
91
67
|
|
92
68
|
def gem_installed?(name, version = nil)
|
93
69
|
if version
|
94
|
-
test(:
|
70
|
+
test(:ruby_installed_gem, name, '--version', "'#{version}'")
|
95
71
|
else
|
96
|
-
test(:
|
72
|
+
test(:ruby_installed_gem, name)
|
97
73
|
end
|
98
74
|
end
|
99
75
|
|
100
76
|
def gem_install(name, version = nil, force = false)
|
101
77
|
if version
|
102
|
-
|
78
|
+
execute(:ruby_install_gem, name, '--version', "'#{version}'", force ? '--force' : '')
|
103
79
|
else
|
104
|
-
|
80
|
+
execute(:ruby_install_gem, name)
|
105
81
|
end
|
106
82
|
end
|
107
83
|
|
108
|
-
def rubygems_install(version)
|
109
|
-
rbenv_exec("gem update --no-document --system '#{version}'")
|
110
|
-
end
|
111
|
-
|
112
84
|
def managed_nodejs?
|
113
85
|
test("[ -f ${HOME}/.nodejs_managed_by_makandra ]")
|
114
86
|
end
|
@@ -9,18 +9,11 @@ namespace :opscomplete do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
namespace :ruby do
|
12
|
-
|
13
|
-
task :rehash do
|
14
|
-
on roles fetch(:rbenv_roles, :all) do
|
15
|
-
execute(:rbenv, :rehash)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Check if rbenv global Ruby version is set according to application\'s .ruby-version.'
|
12
|
+
desc 'Check if Ruby version is set according to application\'s .ruby-version.'
|
20
13
|
task :check do
|
21
14
|
on roles fetch(:rbenv_roles, :all) do |host|
|
22
15
|
warn("#{host}: Managed Ruby environment! Won't do any changes to ruby version.") if managed_ruby?
|
23
|
-
unless capture(:
|
16
|
+
unless capture(:ruby_get_current_version) == app_ruby_version
|
24
17
|
raise Capistrano::ValidationError,
|
25
18
|
"#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure."
|
26
19
|
end
|
@@ -28,61 +21,58 @@ namespace :opscomplete do
|
|
28
21
|
end
|
29
22
|
end
|
30
23
|
|
31
|
-
|
24
|
+
desc 'Install Ruby version management tool dependencies'
|
32
25
|
task :install_ruby_build do
|
33
26
|
on roles fetch(:rbenv_roles, :all) do
|
34
|
-
|
35
|
-
execute :git, :clone, ruby_build_repo_url, rbenv_ruby_build_path
|
27
|
+
execute(:ruby_update_management_tool, :install_build)
|
36
28
|
end
|
37
29
|
end
|
38
30
|
|
39
|
-
|
31
|
+
desc 'Update Ruby version management tool'
|
40
32
|
task :update_ruby_build do
|
41
33
|
on roles fetch(:rbenv_roles, :all) do
|
42
|
-
|
43
|
-
within rbenv_ruby_build_path do
|
44
|
-
execute :git, :pull, '-q'
|
45
|
-
end
|
46
|
-
else
|
47
|
-
warn('Could not find ruby-build.')
|
48
|
-
end
|
34
|
+
execute(:ruby_update_management_tool, :update_build)
|
49
35
|
end
|
50
36
|
end
|
51
37
|
|
52
|
-
|
38
|
+
desc 'Rehash shims (run this after installing executables).'
|
39
|
+
task :rehash do
|
40
|
+
on roles fetch(:rbenv_roles, :all) do
|
41
|
+
execute(:ruby_update_management_tool, :rehash)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Install bundler gem'
|
53
46
|
task :install_bundler do
|
54
47
|
on roles fetch(:rbenv_roles, :all) do
|
55
48
|
# manually specified version will take precedence
|
56
49
|
specific_bundler_version = fetch(:bundler_version, app_gemfile_bundled_with_version)
|
57
|
-
|
58
50
|
if specific_bundler_version
|
59
51
|
# We have to set force = true to overwrite the binary
|
60
52
|
gem_install('bundler', specific_bundler_version, true) unless gem_installed?('bundler', specific_bundler_version)
|
61
53
|
else
|
62
54
|
gem_install('bundler') unless gem_installed?('bundler')
|
63
55
|
end
|
64
|
-
set :rbenv_needs_rehash, true
|
65
56
|
end
|
66
57
|
end
|
67
58
|
|
68
|
-
|
59
|
+
desc 'Install geordi gem'
|
69
60
|
task :install_geordi do
|
70
61
|
on roles fetch(:rbenv_roles, :all) do
|
71
62
|
gem_install('geordi') unless gem_installed?('geordi')
|
72
|
-
set :rbenv_needs_rehash, true
|
73
63
|
end
|
74
64
|
end
|
75
65
|
|
66
|
+
desc 'Install RubyGems'
|
76
67
|
task :install_rubygems do
|
77
68
|
on roles fetch(:rbenv_roles, :all) do
|
78
|
-
# if no rubygems_version was set, we use and don't check the rubygems version
|
69
|
+
# if no rubygems_version was set, we use and don't check the installed rubygems version
|
79
70
|
if fetch(:rubygems_version, false)
|
80
|
-
current_rubygems_version = capture(:
|
71
|
+
current_rubygems_version = capture(:ruby_get_current_version, :rubygems).chomp
|
81
72
|
info("Ensuring requested RubyGems version #{fetch(:rubygems_version)}")
|
82
73
|
next if current_rubygems_version == fetch(:rubygems_version)
|
83
74
|
info("Previously installed RubyGems version was #{current_rubygems_version}")
|
84
|
-
|
85
|
-
set :rbenv_needs_rehash, true
|
75
|
+
execute(:ruby_install_version, :rubygems, "'#{fetch(:rubygems_version)}'")
|
86
76
|
end
|
87
77
|
end
|
88
78
|
end
|
@@ -94,27 +84,26 @@ namespace :opscomplete do
|
|
94
84
|
if managed_ruby?
|
95
85
|
raise Capistrano::ValidationError, "#{host}: Managed Ruby environment! Won't do any changes to Ruby version."
|
96
86
|
end
|
97
|
-
if
|
87
|
+
if ruby_installed_versions.include?(app_ruby_version)
|
98
88
|
info("#{host}: Ruby #{app_ruby_version} is installed.")
|
99
|
-
elsif
|
89
|
+
elsif ruby_installable_versions.include?(app_ruby_version)
|
100
90
|
info("#{host}: Configured Ruby version is not installed, but available for installation.")
|
101
91
|
with tmpdir: fetch(:tmp_dir) do
|
102
|
-
execute(:
|
92
|
+
execute(:ruby_install_version, "'#{app_ruby_version}'")
|
103
93
|
end
|
104
|
-
set :rbenv_needs_rehash, true
|
105
94
|
else
|
106
95
|
raise Capistrano::ValidationError,
|
107
|
-
"#{host}: Configured Ruby version is neither installed nor installable
|
96
|
+
"#{host}: Configured Ruby version is neither installed nor installable."
|
108
97
|
end
|
109
|
-
unless capture(:
|
98
|
+
unless capture(:ruby_get_current_version) == app_ruby_version
|
110
99
|
set :ruby_modified, true
|
111
|
-
execute(:
|
100
|
+
execute(:ruby_set_version, "'#{app_ruby_version}'")
|
112
101
|
end
|
113
102
|
end
|
114
103
|
invoke('opscomplete:ruby:install_rubygems')
|
115
104
|
invoke('opscomplete:ruby:install_bundler')
|
116
105
|
invoke('opscomplete:ruby:install_geordi')
|
117
|
-
invoke('opscomplete:ruby:rehash')
|
106
|
+
invoke('opscomplete:ruby:rehash')
|
118
107
|
end
|
119
108
|
|
120
109
|
desc 'resets the global ruby version and gems to Gemfile and .ruby-version in current_path.'
|
@@ -144,10 +133,10 @@ namespace :opscomplete do
|
|
144
133
|
task :broken_gems_warning do
|
145
134
|
on roles fetch(:rbenv_roles, :all) do |host|
|
146
135
|
if fetch(:ruby_modified, false)
|
147
|
-
warn(
|
148
|
-
warn(
|
149
|
-
warn("If your deploy failed before deploy:symlink:release you may run bundle exec
|
150
|
-
warn(
|
136
|
+
warn('Deploy failed and the ruby version has been modified in this deploy.')
|
137
|
+
warn('If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.')
|
138
|
+
warn("If your deploy failed before deploy:symlink:release you may run bundle exec 'cap #{fetch(:stage)} opscomplete:ruby:reset'.")
|
139
|
+
warn('Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions')
|
151
140
|
else
|
152
141
|
debug("#{host}: Ruby not modified in current deploy.")
|
153
142
|
end
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makandra Operations
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: makandra-rubocop
|