capistrano-s3-copy 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capstrano-s3-copy.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Richie McMahon
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Capistrano::S3::Copy
2
+
3
+ This is a revised implementation of the ideas in Bill Kirtleys capistrano-s3 gem.
4
+
5
+ I have a requirement to push new deployments via capistrano, but also to retain the last
6
+ deployed package in S3 for the purposes of auto-scaling.
7
+
8
+ This gem use Capistrano's own code to build the tarball package, but instead of
9
+ deploying it to each machine, we deploy it to a configured S3 bucket (using s3cmd), then
10
+ deploy it from there to the known nodes from the capistrano script.
11
+
12
+ At some point, I aim to persist a shell script to accompany the package. This will be used
13
+ to instruct a fresh AWS instance how to locate, download and install he S3 package as if
14
+ it was deployed via capistrano.
15
+
16
+ ## Installation
17
+
18
+ Add these line to your application's Gemfile:
19
+
20
+ group :development do
21
+ gem 'capstrano-s3-copy'
22
+ end
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install capistrano-s3-copy
31
+
32
+ ## Usage
33
+
34
+ In your deploy.rb file, we need to tell Capistrano to adopt our new strategy:
35
+
36
+ set :deploy_via, :s3_copy
37
+
38
+ Then we need to provide AWS account details to authorize the upload/download of our
39
+ package to S3
40
+
41
+ set :aws_access_key_id, ENV['AWS_ACCESS_KEY_ID']
42
+ set :aws_secret_access_key, ENV['AWS_SECRET_ACCESS_KEY']
43
+
44
+ Finally, we need to indicate which bucket to store the packages in:
45
+
46
+ set :aws_s3_copy_bucket, 'mybucket-deployments'
47
+
48
+ The package will be stored in S3 prefixed with a rails_env that was set in capistrano:
49
+
50
+ e.g.
51
+
52
+ S3://mybucket-deployment/production/201204212007.tar.gz
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ #rake #!/usr/bin/env rake
2
+ require 'rdoc/task'
3
+ require "bundler/gem_tasks"
4
+
5
+ desc "Build the RDoc API documentation"
6
+ RDoc::Task.new do |rdoc|
7
+ rdoc.rdoc_dir = "doc"
8
+ rdoc.title = "Capistrano S3 Copy"
9
+ rdoc.options += %w(--main README)
10
+ rdoc.rdoc_files.include('README.md', 'LICENSE', 'lib/**/*.rb')
11
+ end
12
+
13
+ desc "Build documentation"
14
+ task :doc => [ :rdoc ]
15
+
16
+ desc "Clean up generated directories and files"
17
+ task :clean do
18
+ rm_rf "pkg"
19
+ rm_rf "doc"
20
+ end
21
+
22
+ task :default => [ :clean, :build, :doc ]
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano-s3-copy/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Richie McMahon"]
6
+ gem.email = ["richie.mcmahon@gmail.com"]
7
+ gem.description = %q{Capistrano deployment strategy that creates and pushes a tarball
8
+ into S3, for both pushed deployments and pulled auto-scaling.}
9
+ gem.summary = %q{Capistrano deployment strategy that transfers the release on S3}
10
+ gem.homepage = "http://github.com/richie/capistrano-s3-copy"
11
+
12
+ gem.add_dependency 'capistrano', ">= 2.12.0"
13
+
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.name = "capistrano-s3-copy"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = Capistrano::S3::Copy::VERSION
20
+ end
@@ -0,0 +1,58 @@
1
+ require 'capistrano/recipes/deploy/strategy/copy'
2
+
3
+ module Capistrano
4
+ module Deploy
5
+ module Strategy
6
+ class S3Copy < Copy
7
+
8
+ S3CMD_VARS = ["aws_access_key_id", "aws_secret_access_key"]
9
+
10
+ def initialize(config={})
11
+ super(config)
12
+
13
+ s3cmd_vars = []
14
+ S3CMD_VARS.each do |var|
15
+ value = configuration[var.to_sym]
16
+ raise Capistrano::Error, "Missing configuration[:#{var}] setting" if value.nil?
17
+ s3cmd_vars << "#{var.upcase}=#{value}"
18
+ end
19
+ @aws_environment = s3cmd_vars.join(" ")
20
+
21
+ @bucket_name = configuration[:aws_s3_copy_bucket]
22
+ raise Capistrano::Error, "Missing configuration[:aws_s3_copy_bucket]" if @bucket_name.nil?
23
+ end
24
+
25
+ def check!
26
+ super.check do |d|
27
+ d.local.command("s3cmd")
28
+ d.remote.command("s3cmd")
29
+ end
30
+ end
31
+
32
+ # Distributes the file to the remote servers
33
+ def distribute!
34
+ package_path = filename
35
+ package_name = File.basename(package_path)
36
+ s3_package = "s3://#{bucket_name}/#{rails_env}/#{package_name}"
37
+ system("#{aws_environment} s3cmd --no-progress put #{package_path} #{s3_package} 2>&1")
38
+
39
+ if $? != 0
40
+ raise Capistrano::Error, "shell command failed with return code #{$?}"
41
+ end
42
+
43
+ run "#{aws_environment} s3cmd get #{bucket_name}:#{rails_env}/#{package_name} #{remote_filename} 2>&1"
44
+ run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
45
+ logger.debug "done!"
46
+ end
47
+
48
+ def aws_environment
49
+ @aws_environment
50
+ end
51
+
52
+ def bucket_name
53
+ @bucket_name
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,7 @@
1
+ module Capistrano
2
+ module S3
3
+ module Copy
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "capistrano-s3-copy/version"
2
+
3
+ module Capistrano
4
+ module S3
5
+ module Copy
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-s3-copy
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Richie McMahon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-04-21 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.12.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: |-
27
+ Capistrano deployment strategy that creates and pushes a tarball
28
+ into S3, for both pushed deployments and pulled auto-scaling.
29
+ email:
30
+ - richie.mcmahon@gmail.com
31
+ executables: []
32
+
33
+ extensions: []
34
+
35
+ extra_rdoc_files: []
36
+
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - capistrano-s3-copy.gemspec
44
+ - lib/capistrano-s3-copy.rb
45
+ - lib/capistrano-s3-copy/version.rb
46
+ - lib/capistrano/recipes/deploy/strategy/s3_copy.rb
47
+ homepage: http://github.com/richie/capistrano-s3-copy
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.11
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Capistrano deployment strategy that transfers the release on S3
74
+ test_files: []
75
+