thunder_punch 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/CHANGELOG.mdown ADDED
@@ -0,0 +1,14 @@
1
+ == 0.0.3 (March 7, 2010)
2
+
3
+ * Fix error in uploading keys to EC2 - missing aws_key_location in the command and upload takes one path at a time [Bob Burbach - github.com/peregrinator]
4
+ * Add roles to the tasks in ami.rb [Bob Burbach - github.com/peregrinator]
5
+ * Add bucket name to store AMI to ec2_config.yml [Bob Burbach - github.com/peregrinator]
6
+
7
+ == 0.0.2 (February 20, 2010)
8
+
9
+ * Add gem dependency for Capistrano >=2.5.5 [Bob Burbach - github.com/peregrinator]
10
+ * Update README with requirements [Bob Burbach - github.com/peregrinator]
11
+
12
+ == 0.0.1 (February 20, 2010)
13
+
14
+ * Initial Creation of Thunder Punch Plugin [Bob Burbach - github.com/peregrinator]
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 GravyCones
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:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
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.
data/Manifest ADDED
@@ -0,0 +1,16 @@
1
+ CHANGELOG.rdoc
2
+ example/ec2_config.yml
3
+ install.rb
4
+ lib/govpulse/thunder_punch.rb
5
+
6
+ lib/govpulse/utilities/utilities.rb
7
+
8
+ lib/govpulse/recipes.rb
9
+ lib/govpulse/recipes/ec2.rb
10
+ lib/govpulse/recipes/ec2/ami.rb
11
+
12
+ Manifest
13
+ MIT-LICENSE
14
+ Rakefile
15
+ README.mdown
16
+ TODO.mdown
data/README.mdown ADDED
@@ -0,0 +1,33 @@
1
+ #Thunder Punch
2
+
3
+ Collection of capistrano recipes for deployment and other server tasks
4
+
5
+ ##Origin
6
+
7
+ "Thunder Punch" was a version of the He-Man action figure from the original 1980s Masters of the Universe toy line. Ring caps were placed in a "backpack" integrated into the figure, which contained the striking mechanism for the caps (as well as tiny vents to allow smoke from a triggered cap to escape). This mechanism was triggered by drawing the figure's spring-loaded right arm back and releasing it to swing forward; the explosion of the cap was intended to simulate a thunderous noise caused by the supposed superhuman power of the character's punch. [via wikipedia]
8
+
9
+ Because this collection of recipes is for capistrano and run with the cap command - this seemed a good name, sans the thunderous noise of course (this was found to be disrupting in work environments and cafes).
10
+
11
+ ##Requirements
12
+
13
+ * Capistrano >=2.5.5
14
+ * In your deploy.rb file:
15
+ * Add line 'require govpulse/thunder_punch'
16
+ * Add line 'set :ec2\_config\_location, File.join(File.dirname(__FILE__), "ec2\_config.yml")'
17
+
18
+ ##Recipes
19
+
20
+ By creating a central and organized system for our tasks we can reduce our deploy.rb files to be project specific and make the addition of new tasks compatible and easily added.
21
+
22
+ ###EC2
23
+
24
+ * Requires a yaml file named ec2_config.yml with the appropriate passwords, etc. See the example file.
25
+ * ami.rb - recipes for uploading neccessary keys to server, bundling new ami, uploading to S3, and registering
26
+
27
+ ##Known Issues
28
+
29
+ ###EC2
30
+
31
+ * ec2:create\_new\_ami task doesn't work at the moment due to the ec2:bundle_ami task not returning properly. See the TODO for more info.
32
+
33
+ Copyright (c) 2010 GravyCones, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "thunder_punch"
8
+ gem.summary = "Collection of capistano recipes for deployment and server tasks"
9
+ gem.description = "Collection of capistano recipes for deployment and server tasks"
10
+ gem.email = "govpulse@gmail.com"
11
+ gem.homepage = "http://github.com/govpulse/thunder_punch"
12
+ gem.authors = ["Bob Burbach"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency('capistrano', '>= 2.5.5')
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "thunder_punch #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/TODO.mdown ADDED
@@ -0,0 +1 @@
1
+ * ec2:bundle_ami task does not return successfully. It completes successfully on the server but does not return. Thus the ec2:create_new_ami task doesn't work at the moment.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,9 @@
1
+ #examples from Amazon documentation
2
+ aws_key_location: ~/.ssh #or where ever you store you aws keys - no trailing slash
3
+ ec2_private_key: pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
4
+ ec2_x509_cert: cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
5
+ aws_account_id: 495219933132
6
+ ec2_architecture: i386
7
+ aws_access_key: <aws-access-key-id>
8
+ aws_secret_access_key: <aws-secret-access-key>
9
+ ec2_s3_bucket_name: some_bucket_for_your_ami_images
@@ -0,0 +1,85 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
+
3
+ namespace :ec2 do
4
+ _cset :ec2_config_loaded, false
5
+ _cset :ec2_config_location, nil
6
+
7
+ task :load_ec2_config, :roles => :app do
8
+ alert_user('You need to set :ec2_config_location in your deploy file', :abort => true) unless ec2_config_location
9
+ alert_user("You must configure your ec2 settings in config/ec2_config.yml", :abort => true) unless File.exist?(ec2_config_location)
10
+
11
+ ec2_config = YAML.load( File.open(ec2_config_location, 'r') )
12
+
13
+ set :aws_key_location, ec2_config['aws_key_location']
14
+ set :ec2_private_key, ec2_config['ec2_private_key']
15
+ set :ec2_x509_cert, ec2_config['ec2_x509_cert']
16
+ set :aws_account_id, ec2_config['aws_account_id']
17
+ set :ec2_architecture, ec2_config['ec2_architecture']
18
+ set :aws_access_key, ec2_config['aws_access_key']
19
+ set :aws_secret_access_key, ec2_config['aws_secret_access_key']
20
+ set :ec2_s3_bucket_name, ec2_config['ec2_s3_bucket_name']
21
+
22
+ alert_user('You need to set :aws_key_location in config/ec2_config.yml', :abort => true) unless :key_location
23
+ alert_user('You need to set :ec2_private_key in config/ec2_config.yml', :abort => true) unless :ec2_private_key
24
+ alert_user('You need to set :ec2_x509_cert in config/ec2_config.yml', :abort => true) unless :ec2_x509_cert
25
+ alert_user('You need to set :aws_account_id in config/ec2_config.yml', :abort => true) unless :aws_account_id
26
+ alert_user('You need to set :ec2_architecture to either "i386" or "x86_64" in config/ec2_config.yml', :abort => true) unless :ec2_architecture
27
+ alert_user('You need to set :aws_access_key in config/ec2_config.yml', :abort => true) unless :aws_access_key
28
+ alert_user('You need to set :aws_secret_access_key in config/ec2_config.yml', :abort => true) unless :aws_secret_access_key
29
+ alert_user('You need to set :ec2_s3_bucket_name in config/ec2_config.yml', :abort => true) unless :ec2_s3_bucket_name
30
+
31
+ set :ec2_config_loaded, true
32
+ end
33
+
34
+ desc 'Bundle new AMI, upload to S3, and register'
35
+ task :create_new_ami, :roles => :app do
36
+ load_ec2_config unless ec2_config_loaded
37
+
38
+ should_copy_keys = Capistrano::CLI.ui.ask "Do you need to copy your keys to the ec2 instance you are creating an AMI from? [Y/n]: "
39
+ while !['Y', 'n'].include?(should_copy_keys)
40
+ puts "\n Please choose Y or n \n"
41
+ should_copy_keys = Capistrano::CLI.ui.ask "Do you need to copy your keys? [Y/n]: "
42
+ end
43
+ copy_keys unless should_copy_keys == 'n'
44
+
45
+ alert_user("You need to set :bundle_name via the command line\n `cap ec2:create_new_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
46
+ bundle_ami
47
+ upload_ami_to_s3
48
+ register_ami
49
+ end
50
+
51
+ desc 'Copy private key and X.509 certificate to server'
52
+ task :copy_keys, :roles => :app do
53
+ load_ec2_config unless ec2_config_loaded
54
+
55
+ alert_user("Ensure you have owner:group set properly on your EC2 /mnt directory or scp will fail!")
56
+
57
+ upload "#{aws_key_location}/#{ec2_private_key}", "/mnt/", :via => :scp
58
+ upload "#{aws_key_location}/#{ec2_x509_cert}", "/mnt/", :via => :scp
59
+ end
60
+
61
+ desc 'Bundle your AMI (including fstab)'
62
+ task :bundle_ami, :roles => :app do
63
+ load_ec2_config unless ec2_config_loaded
64
+ alert_user("You need to set :bundle_name via the command line\n `cap ec2:bundle_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
65
+ sudo "ec2-bundle-vol -d /mnt --fstab /etc/fstab -k /mnt/#{ec2_private_key} -c /mnt/#{ec2_x509_cert} -u #{aws_account_id} -r #{ec2_architecture} -p #{bundle_name}"
66
+ end
67
+
68
+ desc 'Upload your bundled AMI to S3'
69
+ task :upload_ami_to_s3, :roles => :app do
70
+ load_ec2_config unless ec2_config_loaded
71
+ alert_user("You need to set :bundle_name via the command line\n `cap ec2:upload_to_s3 -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
72
+ sudo "ec2-upload-bundle -b #{ec2_s3_bucket_name} -m /mnt/#{bundle_name}.manifest.xml -a #{aws_access_key} -s #{aws_secret_access_key}"
73
+ end
74
+
75
+ desc 'Register your bundled and upload (to S3) AMI'
76
+ task :register_ami, :roles => :app do
77
+ load_ec2_config unless ec2_config_loaded
78
+ alert_user("You need to set :bundle_name via the command line\n `cap ec2:register_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
79
+ ami_description = Capistrano::CLI.ui.ask "Description [enter for none]: "
80
+ run_locally "ec2-register #{ec2_s3_bucket_name}/#{bundle_name}.manifest.xml -n #{bundle_name} -a #{ec2_architecture} -d #{ami_description.dump}"
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -0,0 +1,3 @@
1
+ Dir["#{File.dirname(__FILE__)}/ec2/*.rb"].each { |lib|
2
+ Capistrano::Configuration.instance.load {load(lib)}
3
+ }
@@ -0,0 +1,3 @@
1
+ Dir["#{File.dirname(__FILE__)}/recipes/*.rb"].each { |lib|
2
+ Capistrano::Configuration.instance.load {load(lib)}
3
+ }
@@ -0,0 +1,11 @@
1
+ unless Capistrano::Configuration.respond_to?(:instance)
2
+ abort "Requires Capistrano 2"
3
+ end
4
+
5
+ %w(recipes).each do |filename|
6
+ Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/#{filename}.rb")}
7
+ end
8
+
9
+ Dir["#{File.dirname(__FILE__)}/utilities/*.rb"].each { |lib|
10
+ Capistrano::Configuration.instance.load {load(lib)}
11
+ }
@@ -0,0 +1,19 @@
1
+ # This method is to help format messages to the user in a more recognizable way
2
+ def alert_user(message, options={})
3
+ abort = options.delete(:abort) || false
4
+ wrapped_message = <<-EOF
5
+ \n\n
6
+ *******************************************************************\n
7
+
8
+ #{message} \n
9
+
10
+ *******************************************************************
11
+ \n\n
12
+ EOF
13
+
14
+ if abort
15
+ abort(wrapped_message)
16
+ else
17
+ puts wrapped_message
18
+ end
19
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'thunder_punch'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestThunderPunch < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{thunder_punch}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bob Burbach"]
12
+ s.date = %q{2010-03-07}
13
+ s.description = %q{Collection of capistano recipes for deployment and server tasks}
14
+ s.email = %q{govpulse@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.mdown"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "CHANGELOG.mdown",
22
+ "MIT-LICENSE",
23
+ "Manifest",
24
+ "README.mdown",
25
+ "Rakefile",
26
+ "TODO.mdown",
27
+ "VERSION",
28
+ "example/ec2_config.yml",
29
+ "lib/govpulse/recipes.rb",
30
+ "lib/govpulse/recipes/ec2.rb",
31
+ "lib/govpulse/recipes/ec2/ami.rb",
32
+ "lib/govpulse/thunder_punch.rb",
33
+ "lib/govpulse/utilities/utilities.rb",
34
+ "test/helper.rb",
35
+ "test/test_thunder_punch.rb",
36
+ "thunder_punch.gemspec"
37
+ ]
38
+ s.homepage = %q{http://github.com/govpulse/thunder_punch}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.5}
42
+ s.summary = %q{Collection of capistano recipes for deployment and server tasks}
43
+ s.test_files = [
44
+ "test/helper.rb",
45
+ "test/test_thunder_punch.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_runtime_dependency(%q<capistrano>, [">= 2.5.5"])
55
+ else
56
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
+ s.add_dependency(%q<capistrano>, [">= 2.5.5"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
61
+ s.add_dependency(%q<capistrano>, [">= 2.5.5"])
62
+ end
63
+ end
64
+
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thunder_punch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Bob Burbach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-07 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.5.5
34
+ version:
35
+ description: Collection of capistano recipes for deployment and server tasks
36
+ email: govpulse@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.mdown
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - CHANGELOG.mdown
47
+ - MIT-LICENSE
48
+ - Manifest
49
+ - README.mdown
50
+ - Rakefile
51
+ - TODO.mdown
52
+ - VERSION
53
+ - example/ec2_config.yml
54
+ - lib/govpulse/recipes.rb
55
+ - lib/govpulse/recipes/ec2.rb
56
+ - lib/govpulse/recipes/ec2/ami.rb
57
+ - lib/govpulse/thunder_punch.rb
58
+ - lib/govpulse/utilities/utilities.rb
59
+ - test/helper.rb
60
+ - test/test_thunder_punch.rb
61
+ - thunder_punch.gemspec
62
+ has_rdoc: true
63
+ homepage: http://github.com/govpulse/thunder_punch
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --charset=UTF-8
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.5
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Collection of capistano recipes for deployment and server tasks
90
+ test_files:
91
+ - test/helper.rb
92
+ - test/test_thunder_punch.rb