capistrano-safe-deploy-to 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9f76c0eef83bde034164be33283e133d5f25006b
4
+ data.tar.gz: 4cdbfdb575c7a26e0f5cc510607359225440c37f
5
+ SHA512:
6
+ metadata.gz: bbebe4775b6cacd8dda20e314f81915de4ea15b60b15afcb29f5e9caaee72ce6f78ef1eb5f230d59fafe906ceb7d32038b3aa79bdf8d9676c05bcbb2274650ce
7
+ data.tar.gz: 05b0d52f46b6f13da465e9c6bf8ab272639b4bce4d2d9ad48c58636bc541e0ef196de6482b9821cb4110675081c73105dc83b40f7122f66449ccd200f14c9acd
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in *.gemspec
4
+ gemspec
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2014 Bruno Sutic
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included
11
+ in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # Capistrano::SafeDeployTo
2
+
3
+ A simple Capistrano plugin that:
4
+ - ensures the deployment directory exists on the server
5
+ - ensures proper deployment directory ownership
6
+
7
+ With this, your deployment should **never fail** because you forgot to create a
8
+ deployment directory for your new app on the server.
9
+
10
+ Works with Capistrano 3. Does **not work** with Capistrano 2.
11
+
12
+ ### About
13
+
14
+ You set a Capistrano deployment directory with a `deploy_to` setting. By default
15
+ the value of `deploy_to` is `"/var/www/#{app_name}"`.
16
+
17
+ Your first deploy will **fail** if the `deploy_to` directory does not exist,
18
+ you're not deploying as `root` and your deploy user does not have rights to
19
+ create a deploy directory.
20
+
21
+ And yes, deployment to default `deploy_to` directory **will most likely fail**.
22
+
23
+ That is easy to fix, right? A quick:
24
+ - `ssh yourserver`
25
+ - `sudo mkdir -p /var/www/app_name`
26
+ - `sudo chown deploy:deploy /var/www/app_name`
27
+
28
+ Except that is painful, unnecessary and I refuse to manually `ssh` to the
29
+ server to deploy apps!
30
+
31
+ There are other solutions to this problem (Chef, Ansible), but if you'd like to
32
+ solve it via Capistrano, read on.
33
+
34
+ ### Usage
35
+
36
+ Install with:
37
+
38
+ gem 'capistrano', '~> 3.1'
39
+ gem 'capistrano-safe-deploy-to'
40
+
41
+ then:
42
+
43
+ $ bundle install
44
+
45
+ and then add to `Capfile`:
46
+
47
+ require 'capistrano/safe_deploy_to'
48
+
49
+ And you're done. `$ bundle exec cap production deploy` should just work!
50
+ (or at least it won't fail because directories don't exist).
51
+
52
+ There are no configuration options (thank God!)
53
+
54
+ ### How it works
55
+
56
+ `capistrano-safe-deploy-to` hooks to `before 'deploy:check'` task. It:
57
+ 1. creates s `deploy_to` directory with `sudo mkdir -p <your_deploy_dir>`
58
+ 2. gives proper ownership to deploy dir with
59
+ `sudo chown <deploy_user>:<deploy_user_group> <your_deploy_dir>`
60
+
61
+ It's simple, but you don't have to do or think about it. Let the computers
62
+ slave for you!
63
+
64
+ ### License
65
+
66
+ [MIT](LICENSE.md)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/safe_deploy_to/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "capistrano-safe-deploy-to"
8
+ gem.version = Capistrano::SafeDeployTo::VERSION
9
+ gem.authors = ["Bruno Sutic"]
10
+ gem.email = ["bruno.sutic@gmail.com"]
11
+ gem.description = "Capistrano plugin that ensures the `deploy_to` deployment path exists and has the right permissions."
12
+ gem.summary = "Capistrano plugin that ensures the `deploy_to` deployment path exists and has the right permissions."
13
+ gem.homepage = "https://github.com/bruno-/capistrano-safe-deploy-to"
14
+
15
+ gem.license = "MIT"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+
22
+ gem.add_dependency "capistrano", ">= 3.0"
23
+
24
+ gem.add_development_dependency "rake"
25
+ end
File without changes
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/safe_deploy_to.rake", __FILE__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module SafeDeployTo
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :safe_deploy_to_owner, nil
4
+ set :safe_deploy_to_path, -> { fetch(:deploy_to) }
5
+ end
6
+ end
7
+
8
+ namespace :safe_deploy_to do
9
+ task :create do
10
+ on roles :all do
11
+ sudo :mkdir, '-pv', fetch(:safe_deploy_to_path)
12
+ end
13
+ end
14
+
15
+ task ensure_owner: [:create] do
16
+ on roles :all do
17
+ unless fetch(:safe_deploy_to_owner)
18
+ user = capture :id, '-un'
19
+ group = capture :id, '-gn'
20
+ set :safe_deploy_to_owner, "#{user}:#{group}"
21
+ end
22
+ sudo :chown, fetch(:safe_deploy_to_owner), fetch(:safe_deploy_to_path)
23
+ end
24
+ end
25
+
26
+ desc "Ensures deploy_to directory exists and has the right owner"
27
+ task ensure: [:create, :ensure_owner]
28
+ end
29
+
30
+ before "deploy:check", "safe_deploy_to:ensure"
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-safe-deploy-to
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Sutic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Capistrano plugin that ensures the `deploy_to` deployment path exists
42
+ and has the right permissions.
43
+ email:
44
+ - bruno.sutic@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.md
52
+ - README.md
53
+ - Rakefile
54
+ - capistrano-safe-deploy-to.gemspec
55
+ - lib/capistrano-safe-deploy-to.rb
56
+ - lib/capistrano/safe_deploy_to.rb
57
+ - lib/capistrano/safe_deploy_to/version.rb
58
+ - lib/capistrano/tasks/safe_deploy_to.rake
59
+ homepage: https://github.com/bruno-/capistrano-safe-deploy-to
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.1.5
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Capistrano plugin that ensures the `deploy_to` deployment path exists and
83
+ has the right permissions.
84
+ test_files: []