capistrano-mb 0.32.0 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 88fdfaf1342d807f27c8f0e23b2b8ecd25dc5710
4
- data.tar.gz: a9c1acf1815578c0aec59babf82f28a93db04560
2
+ SHA256:
3
+ metadata.gz: 8d012ef97efa6109de978f625fdaf6d4aae4d78f333f422123b3d381f5a29307
4
+ data.tar.gz: '081b8e13f41d0a3aa9e53275f78e891bf5007788705ec8a4900c9878b0568c1a'
5
5
  SHA512:
6
- metadata.gz: e041aa2192c955e1d92769232caac5536f26121fccad9a6abd92fdcae0403969aaef2c362ba9be71e13f081aea5c7d39a775f64b119a18a6b28525487da6b4ce
7
- data.tar.gz: c95928fbb58a408d8a55403cb0f1bd98468cd3fcbc8216819daf109f0e57a2d54fe683472d0b6fb4b4a4a0a3ba46f956a77f9de2fbfa90948c6302982473857f
6
+ metadata.gz: 0be64b92ed0576bc6b599abdc65dff915b77b6951c1625f8b454eb8a697987a3e1a26fcd63fa620156cc03e7f02fe42bcf7366b3b79e29d9cbf42a791df996ef
7
+ data.tar.gz: ea3c1da247e09e60b954cdd08a2421f80626c9017f34c490372c9b6cfb7e0692965a66cdb402af86a0a0b26a5f9447dc4c6e8514397a8de23e7cab5be3ad7abe
@@ -2,6 +2,14 @@
2
2
 
3
3
  * Your contribution here!
4
4
 
5
+ ## [0.33.0][] (2017-12-29)
6
+
7
+ * Remove the deprecated `fiftyfive` compatibility layer
8
+ * Drop compatibility with older Ubuntu releases; now only Ubuntu 16.04 is supported via a single `provision` task
9
+ * Remove dependencies on `ppa:pitti` and `ppa:chris-lea` for postgres and node.js, respectively; use the official Ubuntu releases instead
10
+ * Replace init_d scripts with systemd configs
11
+ * Completely remove delayed_job support
12
+
5
13
  ## [0.32.0][] (2017-05-26)
6
14
 
7
15
  * Add [immutable cache-control header](https://code.facebook.com/posts/557147474482256) to further boost performance of static assets
@@ -193,7 +201,8 @@ Flush console output after each line is printed. This allows deployment progress
193
201
 
194
202
  Initial Rubygems release!
195
203
 
196
- [Unreleased]: https://github.com/mattbrictson/capistrano-mb/compare/v0.32.0...HEAD
204
+ [Unreleased]: https://github.com/mattbrictson/capistrano-mb/compare/v0.33.0...HEAD
205
+ [0.33.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.32.0...v0.33.0
197
206
  [0.32.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.31.0...v0.32.0
198
207
  [0.31.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.30.0...v0.31.0
199
208
  [0.30.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.29.0...v0.30.0
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # capistrano-mb
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/capistrano-mb.svg)](http://badge.fury.io/rb/capistrano-mb)
3
+ **An opinionated Capistrano task library for deploying Rails apps from scratch on Ubuntu 16.04 LTS.**
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/capistrano-mb.svg)](https://rubygems.org/gems/capistrano-mb)
4
6
 
5
7
  Capistrano is great for deploying Rails applications, but what about all the prerequisites, like Nginx and PostgreSQL? Do you have a firewall configured on your VPS? Have you installed the latest OS security updates? Is HTTPS working right?
6
8
 
@@ -17,9 +19,9 @@ The capistrano-mb gem adds a `cap <stage> provision` task to Capistrano that tak
17
19
  * Install `rbenv` and use `ruby-build` to compile the version of Ruby required by your app (by inspecting your `.ruby-version` file)
18
20
  * And more!
19
21
 
20
- The gem is named "capistrano-mb" because it is prescribes my ([@mattbrictson](https://github.com/mattbrictson)) personal preferences for automating deployments of Rails projects. I'm a freelance developer juggling lots of Rails codebases, so its important for me to have a good, consistent server configuration. You'll notice that capistrano-mb is opinionated and strictly uses the following stack:
22
+ The gem is named "capistrano-mb" because it is prescribes my ([@mattbrictson](https://github.com/mattbrictson)) personal preferences for automating deployments of Rails projects. I've worked several years as a freelance developer juggling lots of Rails codebases, so its important for me to have a good, consistent server configuration. You'll notice that capistrano-mb is opinionated and strictly uses the following stack:
21
23
 
22
- * Ubuntu 14.04 LTS
24
+ * Ubuntu 16.04 LTS
23
25
  * PostgreSQL
24
26
  * Unicorn
25
27
  * Nginx
@@ -30,14 +32,24 @@ In addition, capistrano-mb changes many of Capistrano's defaults, including the
30
32
 
31
33
  Not quite to your liking? Consider forking the project to meet your needs.
32
34
 
35
+ ## Roadmap
36
+
37
+ I plan to continue maintaining this project for the benefit of deploying my own Rails apps for the foreseeable future. In practice, this means a new version of two per year. The behavior of capistrano-mb may change as I upgrade my apps to new versions of Rails. For example, at some point I might:
38
+
39
+ * Replace Unicorn with Puma
40
+ * Switch from dotenv to encrypted credentials
41
+ * Add Let's Encrypt
42
+ * Use a more robust database backup solution
43
+
44
+ *Future changes in capistrano-mb are not guaranteed to have graceful migration paths, so I recommend pinning your Gemfile dependency to a specific version and upgrading with extreme care.*
33
45
 
34
46
  ## Quick start
35
47
 
36
48
  Please note that this project requires **Capistrano 3.x**, which is a complete rewrite of Capistrano 2.x. The two major versions are not compatible.
37
49
 
38
- ### 1. Purchase an Ubuntu 14.04 VPS
50
+ ### 1. Purchase an Ubuntu 16.04 VPS
39
51
 
40
- To use capistrano-mb, you'll need a clean Ubuntu server to deploy to. The only special requirement is that your public SSH key must be installed on the server for the `root` user.
52
+ To use capistrano-mb, you'll need a clean **Ubuntu 16.04** server to deploy to. The only special requirement is that your public SSH key must be installed on the server for the `root` user.
41
53
 
42
54
  Test that you can SSH to the server as `root` without being prompted for a password. If that works, capistrano-mb can take care of the rest. You're ready to proceed!
43
55
 
@@ -46,10 +58,10 @@ Test that you can SSH to the server as `root` without being prompted for a passw
46
58
  capistrano-mb needs to know the version of Ruby that your app requires, so that it can install Ruby during the provisioning process. Place a `.ruby-version` file in the root of your project containing the desired version, like this:
47
59
 
48
60
  ```
49
- 2.2.3
61
+ 2.5.0
50
62
  ```
51
63
 
52
- *If you are using `rbenv`, just run `rbenv local 2.2.3` and it will create this file for you.*
64
+ *If you are using `rbenv`, just run `rbenv local 2.5.0` and it will create this file for you.*
53
65
 
54
66
  ### 3. Gemfile
55
67
 
@@ -67,15 +79,15 @@ Then for the capistrano-mb tools themselves, add these gems to the development g
67
79
  group :development do
68
80
  gem "capistrano-bundler", :require => false
69
81
  gem "capistrano-rails", :require => false
70
- gem "capistrano", "~> 3.4.0", :require => false
71
- gem "capistrano-mb", :require => false
82
+ gem "capistrano", "~> 3.10", :require => false
83
+ gem "capistrano-mb", "~> 0.33.0" :require => false
72
84
  end
73
85
  ```
74
86
 
75
87
  And then execute:
76
88
 
77
89
  ```
78
- $ bundle
90
+ $ bundle install
79
91
  ```
80
92
 
81
93
  ### 4. cap install
@@ -83,7 +95,7 @@ $ bundle
83
95
  If your project doesn't yet have a `Capfile`, run `cap install` with the list of desired stages (environments). For simplicity, this installation guide will assume a single production stage:
84
96
 
85
97
  ```
86
- cap install STAGES=production
98
+ bundle exec cap install STAGES=production
87
99
  ```
88
100
 
89
101
  ### 5. Capfile
@@ -112,14 +124,14 @@ Modify `config/deploy/production.rb` to specify the IP address of your productio
112
124
  ```ruby
113
125
  server "my.production.ip",
114
126
  :user => "deployer",
115
- :roles => %w(app backup cron db web)
127
+ :roles => %w[app backup cron db web]
116
128
  ```
117
129
 
118
130
  *Note that you must include the `backup` and `cron` roles if you want to make use of capistrano-mb's database backups and crontab features.*
119
131
 
120
132
  ### 8. secrets.yml
121
133
 
122
- By default, Rails 4.2 apps have a `config/secrets.yml` file that specifies the Rails secret key. capistrano-mb configures dotenv to provide this secret in a `RAILS_SECRET_KEY_BASE` environment variable. You'll therefore need to modify `secrets.yml` as follows:
134
+ Your Rails apps may have a `config/secrets.yml` file that specifies the Rails secret key. capistrano-mb configures dotenv to provide this secret in a `RAILS_SECRET_KEY_BASE` environment variable. You'll therefore need to modify `secrets.yml` as follows:
123
135
 
124
136
  ```ruby
125
137
  production:
@@ -128,10 +140,10 @@ production:
128
140
 
129
141
  ### 9. Provision and deploy!
130
142
 
131
- Run capistrano-mb's `provision:14_04` task (named for Ubuntu 14.04). This will ask you a few questions, install Ruby, PostgreSQL, Nginx, etc., and set everything up. The entire process takes about 10 minutes (mostly due to compiling Ruby from source).
143
+ Run capistrano-mb's `provision` task. This will ask you a few questions, install Ruby, PostgreSQL, Nginx, etc., and set everything up. The entire process takes about 10 minutes (mostly due to compiling Ruby from source).
132
144
 
133
145
  ```
134
- bundle exec cap production provision:14_04
146
+ bundle exec cap production provision
135
147
  ```
136
148
 
137
149
  Once that's done, your app is now ready to deploy!
@@ -151,8 +163,9 @@ Most of the capistrano-mb recipes are designed to run automatically as part of `
151
163
  The following list will suffice for most out-of-the-box Rails apps. The order of the list is not important.
152
164
 
153
165
  ```ruby
154
- set :mb_recipes, %w(
166
+ set :mb_recipes, %w[
155
167
  aptitude
168
+ bundler
156
169
  crontab
157
170
  dotenv
158
171
  logrotate
@@ -166,7 +179,7 @@ set :mb_recipes, %w(
166
179
  unicorn
167
180
  user
168
181
  version
169
- )
182
+ ]
170
183
  ```
171
184
 
172
185
  Even if you don't include a recipe in the auto-run list, you can still invoke the tasks of those recipes manually at your discretion. Run `bundle exec cap -T` to see the full list of tasks.
@@ -189,9 +202,9 @@ Check out my [rails-template][] project, which generates Rails applications with
189
202
 
190
203
  ## History
191
204
 
192
- This gem used to be called capistrano-fiftyfive, because it was initially built by [55 Minutes](http://55minutes.com) to automate its Rails deployments. I have since taken over ownership of the gem and renamed it to capistrano-mb to avoid any confusion.
205
+ This gem used to be called `capistrano-fiftyfive`. If you are upgrading from capistrano-fiftyfive, refer to the [CHANGELOG entry for v0.22.0](CHANGELOG.md#0220-2015-06-22) for migration instructions.
193
206
 
194
- If you are upgrading from `capistrano-fiftyfive`, refer to the [CHANGELOG entry for v0.22.0](CHANGELOG.md#0220-2015-06-22) for migration instructions.
207
+ As of 0.33.0, capistrano-mb no longer supports Ubuntu 12.04 or 14.04. If your server runs one of these older versions, use [capistrano-mb 0.32.0](https://github.com/mattbrictson/capistrano-mb/tree/v0.32.0).
195
208
 
196
209
  ## Contributing
197
210
 
@@ -9,11 +9,10 @@ Gem::Specification.new do |spec|
9
9
  spec.author = "Matt Brictson"
10
10
  spec.email = "matt@mattbrictson.com"
11
11
  spec.description = \
12
- "Production-ready provisioning and deployment recipes for the full "\
13
- "Rails 4 stack. Installs and configures Ruby, Nginx, Unicorn, "\
14
- "PostgreSQL, dotenv, and more onto Ubuntu 14.04 LTS using Capistrano. "\
15
- "(Note: this gem was formerly called capistrano-fiftyfive.)"
16
- spec.summary = "Additional Capistrano 3 recipes"
12
+ "Production-ready provisioning and deployment recipes for Rails 4 and "\
13
+ "Rails 5 stacks. Installs and configures Ruby, Nginx, Unicorn, "\
14
+ "PostgreSQL, dotenv, and more onto Ubuntu 16.04 LTS using Capistrano."
15
+ spec.summary = "Deploy Rails apps from scratch on Ubuntu 16.04 LTS"
17
16
  spec.homepage = "https://github.com/mattbrictson/capistrano-mb"
18
17
  spec.license = "MIT"
19
18
 
@@ -16,7 +16,6 @@ load File.expand_path("../tasks/dotenv.rake", __FILE__)
16
16
  load File.expand_path("../tasks/postgresql.rake", __FILE__)
17
17
  load File.expand_path("../tasks/nginx.rake", __FILE__)
18
18
  load File.expand_path("../tasks/unicorn.rake", __FILE__)
19
- load File.expand_path("../tasks/delayed_job.rake", __FILE__)
20
19
  load File.expand_path("../tasks/crontab.rake", __FILE__)
21
20
  load File.expand_path("../tasks/logrotate.rake", __FILE__)
22
21
  load File.expand_path("../tasks/rbenv.rake", __FILE__)
@@ -27,4 +26,3 @@ load File.expand_path("../tasks/version.rake", __FILE__)
27
26
  load File.expand_path("../tasks/rake.rake", __FILE__)
28
27
  load File.expand_path("../tasks/sidekiq.rake", __FILE__)
29
28
  load File.expand_path("../tasks/bundler.rake", __FILE__)
30
- load File.expand_path("../tasks/fiftyfive.rake", __FILE__)
@@ -154,45 +154,3 @@ module Capistrano
154
154
  end
155
155
  end
156
156
  end
157
-
158
- require "capistrano/dsl/env"
159
-
160
- module Capistrano
161
- module DSL
162
- module Env
163
- # Overrides capistrano's default `set` to assist developers that are
164
- # migrating from the `fiftyfive_*` to `mb_*` variable names. This will
165
- # be removed in a future version of capistrano-mb.
166
- alias_method :_orig_capistrano_set, :set
167
- def set(name, *args, &block)
168
- if name.to_s =~ /^fiftyfive_/
169
- mb_name = name.to_s.gsub(/^fiftyfive_/, "mb_")
170
- compatibility_warning(
171
- "Use `set :#{mb_name}` instead of `set :#{name}` to ensure "\
172
- "compatibility with future versions of capistrano-mb. The "\
173
- "fiftyfive_* names have been deprecated."
174
- )
175
- name = mb_name.intern
176
- end
177
- _orig_capistrano_set(name, *args, &block)
178
- end
179
-
180
- # Overrides capistrano's default `fetch` to assist developers that are
181
- # migrating from the `fiftyfive_*` to `mb_*` variable names. This will
182
- # be removed in a future version of capistrano-mb.
183
- alias_method :_orig_capistrano_fetch, :fetch
184
- def fetch(name, *args, &block)
185
- if name.to_s =~ /^fiftyfive_/
186
- mb_name = name.to_s.gsub(/^fiftyfive_/, "mb_")
187
- compatibility_warning(
188
- "Use `fetch :#{mb_name}` instead of `fetch :#{name}` to ensure "\
189
- "compatibility with future versions of capistrano-mb. The "\
190
- "fiftyfive_* names have been deprecated."
191
- )
192
- name = mb_name.intern
193
- end
194
- _orig_capistrano_fetch(name, *args, &block)
195
- end
196
- end
197
- end
198
- end
@@ -0,0 +1,20 @@
1
+ [Unit]
2
+ Description=sidekiq worker for <%= fetch(:application) %>
3
+ After=syslog.target network.target
4
+
5
+ [Service]
6
+ Environment=RAILS_ENV=<%= fetch(:rails_env) %>
7
+ ExecStart=/bin/bash -lc 'exec bin/sidekiq -e <%= fetch(:rails_env) %> -P tmp/pids/sidekiq.pid --concurrency <%= fetch(:mb_sidekiq_concurrency) %>'
8
+ PIDFile=<%= current_path %>/tmp/pids/sidekiq.pid
9
+ Restart=on-failure
10
+ RestartSec=1
11
+ StandardError=syslog
12
+ StandardInput=null
13
+ StandardOutput=syslog
14
+ SyslogIdentifier=<%= application_basename %>-sidekiq
15
+ TimeoutStopSec=5
16
+ User=<%= sidekiq_user %>
17
+ WorkingDirectory=<%= current_path %>
18
+
19
+ [Install]
20
+ WantedBy=multi-user.target
@@ -0,0 +1,21 @@
1
+ [Unit]
2
+ Description=unicorn for <%= fetch(:application) %>
3
+ After=syslog.target network.target
4
+
5
+ [Service]
6
+ Environment=RAILS_ENV=<%= fetch(:rails_env) %>
7
+ ExecReload=/usr/bin/kill -USR2 $MAINPID
8
+ ExecStart=/bin/bash -lc 'exec bin/unicorn -c <%= fetch(:mb_unicorn_config) %> -E <%= fetch(:rails_env) %>'
9
+ ExecStop=/usr/bin/kill -QUIT $MAINPID
10
+ PIDFile=<%= fetch(:mb_unicorn_pid) %>
11
+ Restart=always
12
+ StandardError=syslog
13
+ StandardInput=null
14
+ StandardOutput=syslog
15
+ SyslogIdentifier=<%= application_basename %>-unicorn
16
+ TimeoutStopSec=5
17
+ User=<%= unicorn_user %>
18
+ WorkingDirectory=<%= current_path %>
19
+
20
+ [Install]
21
+ WantedBy=multi-user.target
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module MB
3
- VERSION = "0.32.0".freeze
3
+ VERSION = "0.33.0".freeze
4
4
  end
5
5
  end
@@ -1,23 +1,30 @@
1
1
  mb_recipe :aptitude do
2
- during :provision, %w(upgrade install)
3
- before "provision:14_04", "mb:aptitude:install_software_properties"
4
- before "provision:14_04", "mb:aptitude:install_postgres_repo"
5
- before "provision:14_04", "mb:aptitude:change_postgres_packages"
2
+ during :provision, %w[check upgrade install]
6
3
  end
7
4
 
8
5
  namespace :mb do
9
6
  namespace :aptitude do
7
+ desc "Verify server is Ubuntu 16.04"
8
+ task :check do
9
+ privileged_on roles(:all) do
10
+ version = capture(:sudo, "lsb_release -a")[/^Release:\s+(\S+)$/, 1]
11
+ next if version == "16.04"
12
+
13
+ raise "Ubuntu version #{version || "unknown"} is not supported by "\
14
+ "capistrano-mb. Only Ubuntu 16.04 is supported. Downgrade "\
15
+ "capistrano-mb if you need to use an older version of Ubuntu."
16
+ end
17
+ end
10
18
 
11
- desc "Run `aptitude update` and then run `aptitude safe-upgrade`"
19
+ desc "Run `apt update` and then run `apt upgrade`"
12
20
  task :upgrade do
13
- privileged_on roles(:all) do |host|
21
+ privileged_on roles(:all) do
14
22
  _update
15
- _safe_upgrade
23
+ _upgrade
16
24
  end
17
25
  end
18
26
 
19
-
20
- desc "Run `aptitude install` for packages required by the roles of "\
27
+ desc "Run `apt install` for packages required by the roles of "\
21
28
  "each server."
22
29
  task :install do
23
30
  privileged_on roles(:all) do |host|
@@ -37,69 +44,39 @@ namespace :mb do
37
44
  end
38
45
  end
39
46
 
40
- desc "Add the official apt repository for PostgreSQL"
41
- task :install_postgres_repo do
42
- privileged_on roles(:all) do |host|
43
- _add_repository(
44
- "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main",
45
- :key => "https://www.postgresql.org/media/keys/ACCC4CF8.asc")
46
- end
47
- end
48
-
49
- desc "Change 12.04 PostgreSQL package requirements to 14.04 versions"
50
- task :change_postgres_packages do
51
- packages = fetch(:mb_aptitude_packages, {})
52
- packages = Hash[packages.map do |key, value|
53
- [key.sub(/@ppa:pitti\/postgresql$/, ""), value]
54
- end]
55
- set(:mb_aptitude_packages, packages)
56
- end
57
-
58
- desc "Install package needed for apt-add-repository on 14.04"
59
- task :install_software_properties do
60
- privileged_on roles(:all) do |host|
61
- unless _already_installed?("software-properties-common")
62
- _install("software-properties-common")
63
- end
64
- end
65
- end
66
-
67
47
  def _already_installed?(pkg)
68
- test(:sudo, "dpkg", "-s", pkg, "2>/dev/null", "|", :grep, "-q 'ok installed'")
48
+ test(:sudo,
49
+ "dpkg", "-s", pkg,
50
+ "2>/dev/null", "|", :grep, "-q 'ok installed'")
69
51
  end
70
52
 
71
- def _add_repository(repo, options={})
72
- unless _already_installed?("python-software-properties")
73
- _install("python-software-properties")
53
+ def _add_repository(repo)
54
+ unless _already_installed?("software-properties-common")
55
+ _install("software-properties-common")
74
56
  end
75
57
  execute :sudo, "apt-add-repository", "-y '#{repo}'"
76
-
77
- if (key = options.fetch(:key, nil))
78
- execute "wget --prefer-family=IPv4 --quiet -O - #{key} | sudo apt-key add -"
79
- end
80
58
  end
81
59
 
82
60
  def _install(pkg)
83
- with :debian_frontend => "noninteractive" do
84
- execute :sudo, "aptitude", "-y -q install", pkg
85
- end
61
+ execute :sudo, "DEBIAN_FRONTEND=noninteractive apt-get -y install", pkg
86
62
  end
87
63
 
88
64
  def _update
89
- with :debian_frontend => "noninteractive" do
90
- execute :sudo, "aptitude", "-q -q -y update"
91
- end
65
+ execute :sudo, "DEBIAN_FRONTEND=noninteractive apt-get -y update"
92
66
  end
93
67
 
94
- def _safe_upgrade
95
- with :debian_frontend => "noninteractive" do
96
- execute :sudo, "aptitude", "-q -q -y safe-upgrade"
97
- end
68
+ def _upgrade
69
+ execute :sudo,
70
+ "DEBIAN_FRONTEND=noninteractive apt-get -y "\
71
+ '-o DPkg::options::="--force-confdef" '\
72
+ '-o DPkg::options::="--force-confold" '\
73
+ "upgrade"
98
74
  end
99
75
 
100
76
  def _each_package(host)
101
77
  return to_enum(:_each_package, host) unless block_given?
102
78
  hostname = host.hostname
79
+
103
80
  fetch(:mb_aptitude_packages).each do |package_spec, *role_list|
104
81
  next unless roles(*role_list.flatten).map(&:hostname).include?(hostname)
105
82
 
@@ -22,32 +22,29 @@ namespace :load do
22
22
  set :mb_privileged_user, "root"
23
23
 
24
24
  set :mb_aptitude_packages,
25
- "build-essential" => :all,
26
- "curl" => :all,
27
- "debian-goodies" => :all,
28
- "git-core" => :all,
29
- "libpq-dev@ppa:pitti/postgresql" => :all,
30
- "libreadline-gplv2-dev" => :all,
31
- "libssl-dev" => :all,
32
- "libxml2" => :all,
33
- "libxml2-dev" => :all,
34
- "libxslt1-dev" => :all,
35
- "nginx@ppa:nginx/stable" => :web,
36
- "nodejs@ppa:chris-lea/node.js" => :all,
37
- "ntp" => :all,
38
- "postgresql-client@ppa:pitti/postgresql" => :all,
39
- "postgresql@ppa:pitti/postgresql" => :db,
40
- "tklib" => :all,
41
- "ufw" => :all,
42
- "zlib1g-dev" => :all
25
+ "build-essential" => :all,
26
+ "curl" => :all,
27
+ "debian-goodies" => :all,
28
+ "git-core" => :all,
29
+ "libpq-dev" => :all,
30
+ "libreadline-gplv2-dev" => :all,
31
+ "libssl-dev" => :all,
32
+ "libxml2" => :all,
33
+ "libxml2-dev" => :all,
34
+ "libxslt1-dev" => :all,
35
+ "nginx@ppa:nginx/stable" => :web,
36
+ "nodejs" => :all,
37
+ "ntp" => :all,
38
+ "postgresql" => :db,
39
+ "postgresql-client" => :all,
40
+ "tklib" => :all,
41
+ "ufw" => :all,
42
+ "zlib1g-dev" => :all
43
43
 
44
44
  set :mb_bundler_lockfile, "Gemfile.lock"
45
45
  set :mb_bundler_gem_install_command,
46
46
  "gem install bundler --conservative --no-document"
47
47
 
48
- set :mb_delayed_job_args, "-n 2"
49
- set :mb_delayed_job_script, "bin/delayed_job"
50
-
51
48
  set :mb_dotenv_keys, %w(rails_secret_key_base postmark_api_key)
52
49
  set :mb_dotenv_filename, -> { ".env.#{fetch(:rails_env)}" }
53
50
 
@@ -1,5 +1,5 @@
1
1
  mb_recipe :sidekiq do
2
- during :provision, "init_d"
2
+ during :provision, "systemd"
3
3
  during "deploy:start", "start"
4
4
  during "deploy:stop", "stop"
5
5
  during "deploy:restart", "restart"
@@ -8,35 +8,38 @@ end
8
8
 
9
9
  namespace :mb do
10
10
  namespace :sidekiq do
11
- desc "Install sidekiq service script"
12
- task :init_d do
11
+ desc "Install sidekiq systemd config"
12
+ task :systemd do
13
13
  privileged_on roles(fetch(:mb_sidekiq_role)) do |host, user|
14
- template "sidekiq_init.erb",
15
- "/etc/init.d/sidekiq_#{application_basename}",
14
+ sidekiq_user = fetch(:mb_sidekiq_user) || user
15
+
16
+ template "sidekiq.service.erb",
17
+ "/etc/systemd/system/sidekiq_#{application_basename}.service",
16
18
  :mode => "a+rx",
17
19
  :binding => binding,
18
20
  :sudo => true
19
21
 
20
- execute "sudo update-rc.d -f sidekiq_#{application_basename} defaults"
22
+ execute :sudo, "systemctl daemon-reload"
23
+ execute :sudo, "systemctl enable sidekiq_#{application_basename}.service"
24
+
25
+ unless test(:sudo, "grep -qs sidekiq_#{application_basename}.service /etc/sudoers.d/#{user}")
26
+ execute :sudo, "touch -f /etc/sudoers.d/#{user}"
27
+ execute :sudo, "chmod u+w /etc/sudoers.d/#{user}"
28
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl start sidekiq_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
29
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl stop sidekiq_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
30
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl restart sidekiq_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
31
+ execute :sudo, "chmod 440 /etc/sudoers.d/#{user}"
32
+ end
21
33
  end
22
34
  end
23
35
 
24
- %w[start stop].each do |command|
36
+ %w[start stop restart].each do |command|
25
37
  desc "#{command} sidekiq"
26
38
  task command do
27
39
  on roles(fetch(:mb_sidekiq_role)) do
28
- execute "service sidekiq_#{application_basename} #{command}"
40
+ execute :sudo, "systemctl #{command} sidekiq_#{application_basename}.service"
29
41
  end
30
42
  end
31
43
  end
32
-
33
- desc "restart sidekiq"
34
- task :restart do
35
- # Re-enable the "stop" task, just in case we called it once already
36
- # (as would happen during deploy:migrate_and_restart).
37
- Rake::Task["mb:sidekiq:stop"].reenable
38
- invoke "mb:sidekiq:stop"
39
- invoke "mb:sidekiq:start"
40
- end
41
44
  end
42
45
  end
@@ -1,5 +1,5 @@
1
1
  mb_recipe :unicorn do
2
- during :provision, %w(init_d config_rb)
2
+ during :provision, %w(systemd config_rb)
3
3
  during "deploy:start", "start"
4
4
  during "deploy:stop", "stop"
5
5
  during "deploy:restart", "restart"
@@ -8,18 +8,28 @@ end
8
8
 
9
9
  namespace :mb do
10
10
  namespace :unicorn do
11
- desc "Install service script for unicorn"
12
- task :init_d do
11
+ desc "Install unicorn systemd config"
12
+ task :systemd do
13
13
  privileged_on roles(:app) do |host, user|
14
14
  unicorn_user = fetch(:mb_unicorn_user) || user
15
15
 
16
- template "unicorn_init.erb",
17
- "/etc/init.d/unicorn_#{application_basename}",
16
+ template "unicorn.service.erb",
17
+ "/etc/systemd/system/unicorn_#{application_basename}.service",
18
18
  :mode => "a+rx",
19
19
  :binding => binding,
20
20
  :sudo => true
21
21
 
22
- execute "sudo update-rc.d -f unicorn_#{application_basename} defaults"
22
+ execute :sudo, "systemctl daemon-reload"
23
+ execute :sudo, "systemctl enable unicorn_#{application_basename}.service"
24
+
25
+ unless test(:sudo, "grep -qs unicorn_#{application_basename}.service /etc/sudoers.d/#{user}")
26
+ execute :sudo, "touch -f /etc/sudoers.d/#{user}"
27
+ execute :sudo, "chmod u+w /etc/sudoers.d/#{user}"
28
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl start unicorn_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
29
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl stop unicorn_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
30
+ execute :sudo, "echo '#{user} ALL=NOPASSWD: /bin/systemctl restart unicorn_#{application_basename}.service' >> /etc/sudoers.d/#{user}"
31
+ execute :sudo, "chmod 440 /etc/sudoers.d/#{user}"
32
+ end
23
33
  end
24
34
  end
25
35
 
@@ -34,7 +44,7 @@ namespace :mb do
34
44
  desc "#{command} unicorn"
35
45
  task command do
36
46
  on roles(:app) do
37
- execute "service unicorn_#{application_basename} #{command}"
47
+ execute :sudo, "systemctl #{command} unicorn_#{application_basename}.service"
38
48
  end
39
49
  end
40
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-mb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.0
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-26 00:00:00.000000000 Z
11
+ date: 2017-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -80,9 +80,9 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: 'Production-ready provisioning and deployment recipes for the full Rails
84
- 4 stack. Installs and configures Ruby, Nginx, Unicorn, PostgreSQL, dotenv, and more
85
- onto Ubuntu 14.04 LTS using Capistrano. (Note: this gem was formerly called capistrano-fiftyfive.)'
83
+ description: Production-ready provisioning and deployment recipes for Rails 4 and
84
+ Rails 5 stacks. Installs and configures Ruby, Nginx, Unicorn, PostgreSQL, dotenv,
85
+ and more onto Ubuntu 16.04 LTS using Capistrano.
86
86
  email: matt@mattbrictson.com
87
87
  executables: []
88
88
  extensions: []
@@ -95,14 +95,12 @@ files:
95
95
  - README.md
96
96
  - Rakefile
97
97
  - capistrano-mb.gemspec
98
- - lib/capistrano/fiftyfive.rb
99
98
  - lib/capistrano/mb.rb
100
99
  - lib/capistrano/mb/compatibility.rb
101
100
  - lib/capistrano/mb/dsl.rb
102
101
  - lib/capistrano/mb/recipe.rb
103
102
  - lib/capistrano/mb/templates/crontab.erb
104
103
  - lib/capistrano/mb/templates/csr_config.erb
105
- - lib/capistrano/mb/templates/delayed_job_init.erb
106
104
  - lib/capistrano/mb/templates/logrotate.erb
107
105
  - lib/capistrano/mb/templates/maintenance.html.erb
108
106
  - lib/capistrano/mb/templates/nginx.erb
@@ -110,19 +108,17 @@ files:
110
108
  - lib/capistrano/mb/templates/pgpass.erb
111
109
  - lib/capistrano/mb/templates/postgresql-backup-logrotate.erb
112
110
  - lib/capistrano/mb/templates/rbenv_bashrc
113
- - lib/capistrano/mb/templates/sidekiq_init.erb
111
+ - lib/capistrano/mb/templates/sidekiq.service.erb
114
112
  - lib/capistrano/mb/templates/ssl_setup
115
113
  - lib/capistrano/mb/templates/unicorn.rb.erb
116
- - lib/capistrano/mb/templates/unicorn_init.erb
114
+ - lib/capistrano/mb/templates/unicorn.service.erb
117
115
  - lib/capistrano/mb/templates/version.rb.erb
118
116
  - lib/capistrano/mb/version.rb
119
117
  - lib/capistrano/tasks/aptitude.rake
120
118
  - lib/capistrano/tasks/bundler.rake
121
119
  - lib/capistrano/tasks/crontab.rake
122
120
  - lib/capistrano/tasks/defaults.rake
123
- - lib/capistrano/tasks/delayed_job.rake
124
121
  - lib/capistrano/tasks/dotenv.rake
125
- - lib/capistrano/tasks/fiftyfive.rake
126
122
  - lib/capistrano/tasks/logrotate.rake
127
123
  - lib/capistrano/tasks/maintenance.rake
128
124
  - lib/capistrano/tasks/migrate.rake
@@ -158,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
154
  version: '0'
159
155
  requirements: []
160
156
  rubyforge_project:
161
- rubygems_version: 2.6.12
157
+ rubygems_version: 2.7.3
162
158
  signing_key:
163
159
  specification_version: 4
164
- summary: Additional Capistrano 3 recipes
160
+ summary: Deploy Rails apps from scratch on Ubuntu 16.04 LTS
165
161
  test_files: []
@@ -1,6 +0,0 @@
1
- require "capistrano/mb"
2
-
3
- compatibility_warning(
4
- "The capistrano-fiftyfive gem has been renamed to capistrano-mb. "\
5
- 'Use `require "capistrano/mb"` to ensure compatibility with future versions.'
6
- )
@@ -1,36 +0,0 @@
1
- #!/bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: delayed_job
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Manage delayed_job worker
9
- # Description: Start, stop, restart delayed_job workers for a specific application.
10
- ### END INIT INFO
11
- set -e
12
-
13
- # Feel free to change any of the following variables for your app:
14
- CMD="cd <%= current_path %>; RAILS_ENV=<%= fetch(:rails_env) %> <%= fetch(:mb_delayed_job_script) %>"
15
- AS_USER=<%= fetch(:mb_delayed_job_user, user) %>
16
- set -u
17
-
18
- run () {
19
- if [ "$(id -un)" = "$AS_USER" ]; then
20
- eval $1
21
- else
22
- su -c "$1" - $AS_USER
23
- fi
24
- }
25
-
26
- case "$1" in
27
- start)
28
- run "$CMD start <%= fetch(:mb_delayed_job_args) %>"
29
- ;;
30
- stop)
31
- run "$CMD stop"
32
- ;;
33
- restart)
34
- run "$CMD restart <%= fetch(:mb_delayed_job_args) %>"
35
- ;;
36
- esac
@@ -1,100 +0,0 @@
1
- #!/bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: sidekiq
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Manage sidekiq worker
9
- # Description: Start, stop, restart sidekiq worker.
10
- ### END INIT INFO
11
-
12
- APP_DIR="<%= current_path %>"
13
- LOG_FILE="$APP_DIR/log/sidekiq.log"
14
- PID_FILE="$APP_DIR/tmp/pids/sidekiq.pid"
15
- SIDEKIQ="sidekiq"
16
- SIDEKIQCTL="sidekiqctl"
17
- APP_ENV="<%= fetch(:rails_env) %>"
18
- BUNDLE="bundle"
19
- AS_USER=<%= fetch(:mb_sidekiq_user, user) %>
20
- CONCURRENCY=<%= fetch(:mb_sidekiq_concurrency) %>
21
-
22
- START_CMD="cd $APP_DIR; $BUNDLE exec $SIDEKIQ -d -e $APP_ENV -P $PID_FILE --concurrency $CONCURRENCY -L $LOG_FILE"
23
- CTL_CMD="cd $APP_DIR; $BUNDLE exec $SIDEKIQCTL"
24
- RETVAL=0
25
-
26
-
27
- run () {
28
- if [ "$(id -un)" = "$AS_USER" ]; then
29
- eval $1
30
- else
31
- su -c "$1" - $AS_USER
32
- fi
33
- }
34
-
35
- start() {
36
-
37
- status
38
- if [ $? -eq 1 ]; then
39
-
40
- [ -d $APP_DIR ] || (echo "$APP_DIR not found!.. Exiting"; exit 6)
41
- echo "Starting $SIDEKIQ message processor .. "
42
- run "$START_CMD"
43
- RETVAL=$?
44
- #Sleeping for 8 seconds for process to be precisely visible in process table - See status ()
45
- sleep 8
46
- return $RETVAL
47
- else
48
- echo "$SIDEKIQ message processor is already running .. "
49
- fi
50
-
51
-
52
- }
53
-
54
- stop() {
55
-
56
- status
57
- if [ $? -eq 0 ]; then
58
-
59
- echo "Stopping $SIDEKIQ message processor .."
60
- run "$CTL_CMD stop $PID_FILE"
61
- RETVAL=$?
62
- return $RETVAL
63
-
64
- else
65
- echo "$SIDEKIQ message processor is already stopped .. "
66
- fi
67
-
68
- }
69
-
70
- status() {
71
-
72
- ps -ef | egrep 'sidekiq [0-9]+.[0-9]+.[0-9]+' | grep -v grep
73
- return $?
74
- }
75
-
76
-
77
- case "$1" in
78
- start)
79
- start
80
- ;;
81
- stop)
82
- stop
83
- ;;
84
- status)
85
- status
86
-
87
- if [ $? -eq 0 ]; then
88
- echo "$SIDEKIQ message processor is running .."
89
- RETVAL=0
90
- else
91
- echo "$SIDEKIQ message processor is stopped .."
92
- RETVAL=1
93
- fi
94
- ;;
95
- *)
96
- echo "Usage: $0 {start|stop|status}"
97
- exit 0
98
- ;;
99
- esac
100
- exit $RETVAL
@@ -1,84 +0,0 @@
1
- #!/bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: unicorn
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Manage unicorn server
9
- # Description: Start, stop, restart unicorn server for a specific application.
10
- ### END INIT INFO
11
- set -e
12
-
13
- # Feel free to change any of the following variables for your app:
14
- TIMEOUT=${TIMEOUT-60}
15
- APP_ROOT=<%= current_path %>
16
- PID=<%= fetch(:mb_unicorn_pid) %>
17
- CMD="cd <%= current_path %>; bundle exec unicorn -D -c <%= fetch(:mb_unicorn_config) %> -E <%= fetch(:rails_env) %>"
18
- AS_USER=<%= unicorn_user %>
19
- set -u
20
-
21
- OLD_PIN="$PID.oldbin"
22
-
23
- sig () {
24
- test -s "$PID" && kill -$1 `cat $PID`
25
- }
26
-
27
- oldsig () {
28
- test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
29
- }
30
-
31
- run () {
32
- if [ "$(id -un)" = "$AS_USER" ]; then
33
- eval $1
34
- else
35
- su -c "$1" - $AS_USER
36
- fi
37
- }
38
-
39
- case "$1" in
40
- start)
41
- sig 0 && echo >&2 "Already running" && exit 0
42
- run "$CMD"
43
- ;;
44
- stop)
45
- sig QUIT && exit 0
46
- echo >&2 "Not running"
47
- ;;
48
- force-stop)
49
- sig TERM && exit 0
50
- echo >&2 "Not running"
51
- ;;
52
- restart|reload)
53
- sig USR2 && echo reloaded OK && exit 0
54
- echo >&2 "Couldn't reload, starting '$CMD' instead"
55
- run "$CMD"
56
- ;;
57
- upgrade)
58
- if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
59
- then
60
- n=$TIMEOUT
61
- while test -s $OLD_PIN && test $n -ge 0
62
- do
63
- printf '.' && sleep 1 && n=$(( $n - 1 ))
64
- done
65
- echo
66
-
67
- if test $n -lt 0 && test -s $OLD_PIN
68
- then
69
- echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
70
- exit 1
71
- fi
72
- exit 0
73
- fi
74
- echo >&2 "Couldn't upgrade, starting '$CMD' instead"
75
- run "$CMD"
76
- ;;
77
- reopen-logs)
78
- sig USR1
79
- ;;
80
- *)
81
- echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
82
- exit 1
83
- ;;
84
- esac
@@ -1,33 +0,0 @@
1
- mb_recipe :delayed_job do
2
- during :provision, "init_d"
3
- during "deploy:start", "start"
4
- during "deploy:stop", "stop"
5
- during "deploy:restart", "restart"
6
- during "deploy:publishing", "restart"
7
- end
8
-
9
- namespace :mb do
10
- namespace :delayed_job do
11
- desc "Install delayed_job service script"
12
- task :init_d do
13
- privileged_on roles(:delayed_job) do |host, user|
14
- template "delayed_job_init.erb",
15
- "/etc/init.d/delayed_job_#{application_basename}",
16
- :mode => "a+rx",
17
- :binding => binding,
18
- :sudo => true
19
-
20
- execute "sudo update-rc.d -f delayed_job_#{application_basename} defaults"
21
- end
22
- end
23
-
24
- %w[start stop restart].each do |command|
25
- desc "#{command} delayed_job"
26
- task command do
27
- on roles(:delayed_job) do
28
- execute "service delayed_job_#{application_basename} #{command}"
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,59 +0,0 @@
1
- # Provides backward compatibility with the old "fiftyfive" task names.
2
-
3
- tasks = %w(
4
- fiftyfive:aptitude:change_postgres_packages
5
- fiftyfive:aptitude:install
6
- fiftyfive:aptitude:install_postgres_repo
7
- fiftyfive:aptitude:upgrade
8
- fiftyfive:crontab
9
- fiftyfive:delayed_job:init_d
10
- fiftyfive:delayed_job:restart
11
- fiftyfive:delayed_job:start
12
- fiftyfive:delayed_job:stop
13
- fiftyfive:dotenv:replace
14
- fiftyfive:dotenv:update
15
- fiftyfive:logrotate
16
- fiftyfive:maintenance:disable
17
- fiftyfive:maintenance:enable
18
- fiftyfive:migrate:deploy
19
- fiftyfive:nginx:configure
20
- fiftyfive:nginx:restart
21
- fiftyfive:nginx:start
22
- fiftyfive:nginx:stop
23
- fiftyfive:postgresql:create_database
24
- fiftyfive:postgresql:create_user
25
- fiftyfive:postgresql:database_yml
26
- fiftyfive:postgresql:dump
27
- fiftyfive:postgresql:logrotate_backup
28
- fiftyfive:postgresql:pgpass
29
- fiftyfive:postgresql:restore
30
- fiftyfive:postgresql:tune
31
- fiftyfive:rake
32
- fiftyfive:rbenv:install
33
- fiftyfive:rbenv:upgrade
34
- fiftyfive:seed
35
- fiftyfive:sidekiq:init_d
36
- fiftyfive:sidekiq:restart
37
- fiftyfive:sidekiq:start
38
- fiftyfive:sidekiq:stop
39
- fiftyfive:ssl:generate_csr
40
- fiftyfive:ssl:generate_dh
41
- fiftyfive:ssl:generate_self_signed_crt
42
- fiftyfive:ufw:configure
43
- fiftyfive:unicorn:config_rb
44
- fiftyfive:unicorn:init_d
45
- fiftyfive:unicorn:restart
46
- fiftyfive:unicorn:start
47
- fiftyfive:unicorn:stop
48
- fiftyfive:user:add
49
- fiftyfive:user:install_public_key
50
- fiftyfive:version:write_initializer
51
- )
52
-
53
- tasks.each do |name|
54
- task(name) do
55
- mb_name = name.gsub(/^fiftyfive:/, "mb:")
56
- compatibility_warning("The #{name} task has been renamed to #{mb_name}.")
57
- invoke(mb_name)
58
- end
59
- end