dlss-capistrano 3.4.0 → 3.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 401c91b9bcf9711f8503d30133b8ae23d6270c13
4
- data.tar.gz: de0a7413ead1776f1969a5770f5eed682f1b1ace
2
+ SHA256:
3
+ metadata.gz: 7eea74ee6a9ac9242202225bf1f5483e90bdeb69cdac2610023991f665d6c205
4
+ data.tar.gz: c0e1dad48ea7b768620c6f4e067daae07068441e667534c22c8360cf2adfb649
5
5
  SHA512:
6
- metadata.gz: 44895bd8295e04b3b5cb769af89dbc6912aa613612416dadd0580c22a83b002a9837290d20db4b906da943c373fc66ea52b1af70d4755da53019599129f33e74
7
- data.tar.gz: 85b681f6633951e3f1540d9486c38a59095bb535356db39675fa947268808f6aa4f61b5f153e03fecf45960fcb4fb443967faa6c01eb1664c3ca95ebcebcc05a
6
+ metadata.gz: 249eefe27bc33417be80b1418c82fcb1766658e3fa4f35807725d98492e2eeeec3db8d92eccc3eff5a1d3cac5cc937007a41a25d547f168770e93c77449a2a72
7
+ data.tar.gz: 8ebf45a2df37fd94887f14c37e9aec109ab4aa939cd45ad5f413273c9fe2e3a3d7cd749c26892b1cc859aa8de67ad1d573476a113832a7b3644b081d119f9a91
@@ -0,0 +1,12 @@
1
+ ## Why was this change made?
2
+
3
+
4
+
5
+ ## How was this change tested?
6
+
7
+
8
+
9
+ ## Which documentation and/or configurations were updated?
10
+
11
+
12
+
data/LICENSE CHANGED
@@ -1,20 +1,13 @@
1
- Copyright (c) 2009 Stanford University Library
1
+ Copyright 2017 The Board of Trustees of the Leland Stanford Junior University
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
10
6
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
7
+ http://www.apache.org/licenses/LICENSE-2.0
13
8
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md CHANGED
@@ -1,21 +1,87 @@
1
1
  # dlss-capistrano
2
2
 
3
- This gem contains classes that deal with the Capistrano deployment of SUL DLSS Ruby projects.
3
+ [![Gem Version](https://badge.fury.io/rb/dlss-capistrano.svg)](https://badge.fury.io/rb/dlss-capistrano)
4
4
 
5
- ## Capfile assumptions
5
+ This gem provides Capistrano deployment tasks used by Stanford Libraries' Digital Library Systems and Services group.
6
6
 
7
- This gem makes the following assumptions about your Ruby project
7
+ ## Included Tasks
8
+
9
+ ### Bundle 2-style Configuration
10
+
11
+ To override the capistrano-bundler gem and use Bundler 2-style configuration without using deprecated arguments, you can set the following settings in `config/deploy.rb`:
12
+
13
+ ```ruby
14
+ set :bundler2_config_use_hook, true # this is how to opt-in to bundler 2-style config. it's false by default
15
+ set :bundler2_config_roles, [:app] # feel free to add roles to this array if you need them
16
+ set :bundler2_config_deployment, true # this is true by default
17
+ set :bundler2_config_without, 'production' # exclude development, and test bundle groups by default
18
+ set :bundler2_config_path, '/tmp' # set to '#{shared_path}/bundle' by default
19
+ ```
20
+
21
+ Note that only `bundler2_config_use_hook` **must** be set in order to use this functionality.
22
+
23
+ ### Sidekiq symlink
24
+
25
+ Every time the version of Sidekiq or Ruby changes, a corresponding Puppet PR must be made in order to update the XSendFilePath that allows Apache to access the bundled Sidekiq gem's assets. dlss-capistrano provides a hook to create a symlink to the bundled Sidekiq to avoid having to do this:
26
+
27
+ ```ruby
28
+ set :bundled_sidekiq_symlink, true # false is the default value
29
+ set :bundled_sidekiq_roles, [:app] # this is the default value
30
+ ```
31
+
32
+ Set this in `config/deploy.rb` to automate the symlink creation, and then use `XSendFilePath /path/to/my/app/shared/bundled_sidekiq/web/assets` in Apache configuration (in Puppet).
33
+
34
+ ### SSH
35
+
36
+ `cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory
37
+
38
+ ### Display Revision (and branches)
39
+
40
+ `cap ENV deployed_branch` displays the currently deployed revision (commit ID) and any branches containing the revision for each server in `ENV`.
41
+
42
+ ### Sidekiq via systemd
43
+
44
+ `cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
45
+
46
+ These tasks are intended to replace those provided by `capistrano-sidekiq` gem, which has assumptions about systemd that do not apply to our deployed environments.
47
+
48
+ #### Capistrano role
49
+
50
+ The sidekiq_systemd tasks assume a Capistrano role of `:app`. If your application uses a different Capistrano role for hosts that run Sidekiq workers, you can configure this in `config/deploy.rb`, *e.g.*:
51
+
52
+ ```ruby
53
+ set :sidekiq_systemd_role, :worker
54
+ ```
55
+
56
+ #### Deployment hooks
57
+
58
+ The sidekiq_systemd tasks assume you want to hook them into Capistrano deployment on your own. If you want to use the hooks provided by `dlss-capistrano`, you can opt in via `config/deploy.rb`:
59
+
60
+ ```ruby
61
+ set :sidekiq_systemd_use_hooks, true
62
+ ```
63
+
64
+ These are the hooks provided if you opt in:
65
+
66
+ ```ruby
67
+ after 'deploy:failed', 'sidekiq_systemd:restart'
68
+ after 'deploy:published', 'sidekiq_systemd:start'
69
+ after 'deploy:starting', 'sidekiq_systemd:quiet'
70
+ after 'deploy:updated', 'sidekiq_systemd:stop'
71
+ ```
72
+
73
+ ## Assumptions
74
+
75
+ dlss-capistrano makes the following assumptions about your Ruby project
8
76
 
9
77
  - You are using Capistrano 3+
10
78
  - You use git for source control
11
- - The server you deploy to uses rvm, it is installed systemwide, and is the default system ruby
79
+ - The server you deploy to uses rvm, it is installed system-wide, and is the default system ruby
12
80
  - You do not have an .rvmrc checked into git (should be in your .gitignore)
13
81
  - You will not use rvm gemsets on the server you deploy to
14
82
  - Bundler will install specified gems into {your_project_home}/shared/bundle directory
15
- - You have a VERSION file that contains an x.y.z version number. This will get passed to the DLSS release board
16
83
  - Will deploy from the master branch, unless you set :branch to another branch or tag
17
84
 
85
+ ## Copyright
18
86
 
19
- == Copyright
20
-
21
- Copyright (c) 2015 Stanford University Library. See LICENSE for details.
87
+ Copyright (c) 2020 Stanford University. See LICENSE for details.
@@ -4,13 +4,14 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "dlss-capistrano"
7
- s.version = "3.4.0"
7
+ s.version = "3.8.0"
8
8
 
9
9
  s.platform = Gem::Platform::RUBY
10
- s.authors = ["Chris Beer","Willy Mene"]
11
- s.email = ["cabeer@stanford.edu"]
12
- s.summary = "Capistrano recipies for use in SUL/DLSS projects"
13
- s.description = "Capistrano recipies to assist with the development, testing, and release of SUL/DLSS Ruby project"
10
+ s.authors = ["Chris Beer", 'Mike Giarlo']
11
+ s.email = ["cabeer@stanford.edu", 'mjgiarlo@stanford.edu']
12
+ s.summary = "Capistrano recipes for use in SUL/DLSS projects"
13
+ s.description = "Capistrano recipes to assist with development, testing, & deployment of SUL/DLSS Ruby projects"
14
+ s.license = "Apache-2.0"
14
15
 
15
16
  s.required_rubygems_version = ">= 1.3.6"
16
17
  s.required_ruby_version = '>= 1.9.3'
@@ -18,8 +19,7 @@ Gem::Specification.new do |s|
18
19
  # All dependencies are runtime dependencies, since this gem's "runtime" is
19
20
  # the dependent gem's development-time.
20
21
  s.add_dependency "capistrano", "~> 3.0"
21
- s.add_dependency "capistrano-releaseboard"
22
- s.add_dependency "capistrano-bundle_audit", ">= 0.1.0"
22
+ s.add_dependency "capistrano-bundle_audit", ">= 0.3.0"
23
23
  s.add_dependency "capistrano-one_time_key"
24
24
  s.add_dependency "capistrano-shared_configs"
25
25
 
@@ -1,6 +1,5 @@
1
- ENV['RELEASE_BOARD_URL'] ||= "https://dlss-releases.stanford.edu"
2
-
3
1
  require 'capistrano/one_time_key'
4
- require 'capistrano/releaseboard'
5
2
  require 'capistrano/bundle_audit'
6
3
  require 'capistrano/shared_configs'
4
+
5
+ Dir.glob("#{__dir__}/capistrano/tasks/*.rake").each { |r| import r }
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # These tasks exist because capistrano-bundler does not yet have a built-in
4
+ # mechanism for configuring bundler 2 without deprecation warnings. We can dump
5
+ # this if/when https://github.com/capistrano/bundler/issues/115 is resolved.
6
+
7
+ def default_bundle_path
8
+ Pathname.new("#{shared_path}/bundle")
9
+ end
10
+
11
+ namespace :load do
12
+ task :defaults do
13
+ # This provides opt-in behavior. Do nothing if not requested.
14
+ set :bundler2_config_use_hook, fetch(:bundler2_config_use_hook, false)
15
+ set :bundler2_config_roles, fetch(:bundler2_config_roles, [:app])
16
+ set :bundler2_config_deployment, fetch(:bundler2_config_deployment, true)
17
+ set :bundler2_config_without, fetch(:bundler2_config_without, 'development:test')
18
+ # NOTE: `shared_path` is not defined at this point, so we can't set the default value to `default_bundle_path`
19
+ set :bundler2_config_path, fetch(:bundler2_config_path, nil)
20
+ end
21
+ end
22
+
23
+ # Integrate bundle config hook into Capistrano
24
+ namespace :deploy do
25
+ before :starting, :add_bundler2_config_hook do
26
+ invoke 'bundler2:add_hook' if fetch(:bundler2_config_use_hook)
27
+ end
28
+ end
29
+
30
+ namespace :bundler2 do
31
+ # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
32
+ task :add_hook do
33
+ # Override capistrano-bundler settings
34
+ # HT: https://github.com/capistrano/bundler/issues/115#issuecomment-616570236
35
+ set :bundle_flags, '--quiet' # this unsets --deployment, see details in config_bundler task details
36
+ set :bundle_path, nil
37
+ set :bundle_without, nil
38
+
39
+ before 'bundler:install', 'bundler2:config'
40
+ end
41
+
42
+ # NOTE: This task lacks a `desc` to avoid publishing it, since we do not
43
+ # foresee needing to run this task manually. It should run via hook.
44
+ #
45
+ # Configure bundler 2 without using deprecated arguments (overrides capistrano-bundler
46
+ task :config do
47
+ on roles fetch(:bundler2_config_roles) do
48
+ execute "bundle config --local deployment #{fetch(:bundler2_config_deployment)}"
49
+ execute "bundle config --local without '#{fetch(:bundler2_config_without)}'"
50
+ execute "bundle config --local path #{fetch(:bundler2_config_path) || default_bundle_path}"
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ # Capistrano plugin hook to set default values
2
+ namespace :load do
3
+ task :defaults do
4
+ set :bundled_sidekiq_symlink, fetch(:bundled_sidekiq_symlink, false)
5
+ set :bundled_sidekiq_roles, fetch(:bundled_sidekiq_roles, [:app])
6
+ end
7
+ end
8
+
9
+ # Integrate sidekiq-bundle hook into Capistrano
10
+ namespace :deploy do
11
+ before :starting, :add_bundled_sidekiq_hook do
12
+ invoke 'bundled_sidekiq:add_hook' if fetch(:bundled_sidekiq_symlink)
13
+ end
14
+ end
15
+
16
+ namespace :bundled_sidekiq do
17
+ # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
18
+ task :add_hook do
19
+ after 'bundler:install', 'bundled_sidekiq:symlink'
20
+ end
21
+
22
+ # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
23
+ task :symlink do
24
+ on roles fetch(:bundled_sidekiq_roles) do
25
+ within release_path do
26
+ bundled_sidekiq_path = capture(:bundle, :info, '--path', :sidekiq)
27
+ execute(:ln, '-sf', bundled_sidekiq_path, "#{shared_path}/bundled_sidekiq")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ desc 'display the deployed branch and commit'
2
+ task :deployed_branch do
3
+ on roles(:app) do |host|
4
+ within current_path do
5
+ revision = capture :cat, 'REVISION'
6
+ branches = `git branch -r --contains #{revision}`.strip
7
+ info "#{host}: #{revision} (#{branches})"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,52 @@
1
+ # Capistrano plugin hook to set default values
2
+ namespace :load do
3
+ task :defaults do
4
+ set :sidekiq_systemd_role, fetch(:sidekiq_systemd_role, :app)
5
+ set :sidekiq_systemd_use_hooks, fetch(:sidekiq_systemd_use_hooks, false)
6
+ end
7
+ end
8
+
9
+ # Integrate sidekiq hooks into Capistrano
10
+ namespace :deploy do
11
+ before :starting, :add_sidekiq_systemd_hooks do
12
+ invoke 'sidekiq_systemd:add_hooks' if fetch(:sidekiq_systemd_use_hooks)
13
+ end
14
+ end
15
+
16
+ namespace :sidekiq_systemd do
17
+ # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
18
+ task :add_hooks do
19
+ after 'deploy:failed', 'sidekiq_systemd:restart'
20
+ after 'deploy:published', 'sidekiq_systemd:start'
21
+ after 'deploy:starting', 'sidekiq_systemd:quiet'
22
+ after 'deploy:updated', 'sidekiq_systemd:stop'
23
+ end
24
+
25
+ desc 'Stop workers from picking up new jobs'
26
+ task :quiet do
27
+ on roles fetch(:sidekiq_systemd_role) do
28
+ sudo :systemctl, 'reload', 'sidekiq-*', raise_on_non_zero_exit: false
29
+ end
30
+ end
31
+
32
+ desc 'Stop running workers gracefully'
33
+ task :stop do
34
+ on roles fetch(:sidekiq_systemd_role) do
35
+ sudo :systemctl, 'stop', 'sidekiq-*'
36
+ end
37
+ end
38
+
39
+ desc 'Start workers'
40
+ task :start do
41
+ on roles fetch(:sidekiq_systemd_role) do
42
+ sudo :systemctl, 'start', 'sidekiq-*', '--all'
43
+ end
44
+ end
45
+
46
+ desc 'Restart workers'
47
+ task :restart do
48
+ on roles fetch(:sidekiq_systemd_role) do
49
+ sudo :systemctl, 'restart', 'sidekiq-*', raise_on_non_zero_exit: false
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,8 @@
1
+ desc "ssh to the current directory on the server"
2
+ task :ssh do
3
+ on roles(:app), :primary => true do |host|
4
+ command = "cd #{fetch(:deploy_to)}/current && exec $SHELL -l"
5
+ puts command if fetch(:log_level) == :debug
6
+ exec "ssh -l #{host.user} #{host.hostname} -p #{host.port || 22} -t '#{command}'"
7
+ end
8
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dlss-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
- - Willy Mene
8
+ - Mike Giarlo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-13 00:00:00.000000000 Z
12
+ date: 2020-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -25,34 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.0'
28
- - !ruby/object:Gem::Dependency
29
- name: capistrano-releaseboard
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: capistrano-bundle_audit
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - ">="
47
33
  - !ruby/object:Gem::Version
48
- version: 0.1.0
34
+ version: 0.3.0
49
35
  type: :runtime
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
39
  - - ">="
54
40
  - !ruby/object:Gem::Version
55
- version: 0.1.0
41
+ version: 0.3.0
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: capistrano-one_time_key
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -81,14 +67,16 @@ dependencies:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
83
69
  version: '0'
84
- description: Capistrano recipies to assist with the development, testing, and release
85
- of SUL/DLSS Ruby project
70
+ description: Capistrano recipes to assist with development, testing, & deployment
71
+ of SUL/DLSS Ruby projects
86
72
  email:
87
73
  - cabeer@stanford.edu
74
+ - mjgiarlo@stanford.edu
88
75
  executables: []
89
76
  extensions: []
90
77
  extra_rdoc_files: []
91
78
  files:
79
+ - ".github/pull_request_template.md"
92
80
  - ".gitignore"
93
81
  - Gemfile
94
82
  - LICENSE
@@ -97,9 +85,15 @@ files:
97
85
  - dlss-capistrano.gemspec
98
86
  - lib/dlss.rb
99
87
  - lib/dlss/capistrano.rb
88
+ - lib/dlss/capistrano/tasks/bundle_config.rake
89
+ - lib/dlss/capistrano/tasks/bundled_sidekiq.rake
90
+ - lib/dlss/capistrano/tasks/deployed_branch.rake
91
+ - lib/dlss/capistrano/tasks/sidekiq_systemd.rake
92
+ - lib/dlss/capistrano/tasks/ssh.rake
100
93
  - lib/lyberteam-capistrano-devel.rb
101
94
  homepage:
102
- licenses: []
95
+ licenses:
96
+ - Apache-2.0
103
97
  metadata: {}
104
98
  post_install_message:
105
99
  rdoc_options: []
@@ -116,9 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
110
  - !ruby/object:Gem::Version
117
111
  version: 1.3.6
118
112
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.5.1
113
+ rubygems_version: 3.0.3
121
114
  signing_key:
122
115
  specification_version: 4
123
- summary: Capistrano recipies for use in SUL/DLSS projects
116
+ summary: Capistrano recipes for use in SUL/DLSS projects
124
117
  test_files: []