deus_ex 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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/TODO.md +16 -0
- data/bin/deus_ex +8 -0
- data/deus_ex.gemspec +26 -0
- data/lib/deus_ex.rb +13 -0
- data/lib/deus_ex/aws.rb +99 -0
- data/lib/deus_ex/version.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4030dc909cd62c70b03f3193e8908c02528123c3
|
4
|
+
data.tar.gz: 6ed2f7c51203dca69c528d8309d28370947fb0bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f2c76e7b7aabe7b9a17efecb17d1d758668197640524565696a46c99fae1fcc0799519aaba8aeb62647db27054641a94bc95579e4a0bf483c4b0674980a2853
|
7
|
+
data.tar.gz: 0b212b3ef048f8e095fbd1a1d7c3a7bf73c689d637fa67a6911af984a2ddae64fa43e827cf2bb5409af5e437170d9d907955adc433e5c05ad495dc788ae8a51a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ben Scofield
|
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,45 @@
|
|
1
|
+
# DeusEx
|
2
|
+
|
3
|
+
GitHub DDOSings getting you down and stopping your deploys? GIT IS DISTRIBUTED, SUCKA. The deus_ex gem allows you to easily
|
4
|
+
fire up an AWS instance, push your repo to it, and use that for your deploy until GitHub is back on its feet.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'deus_ex'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install deus_ex
|
19
|
+
|
20
|
+
The gem uses [fog](http://fog.io/) to manage the connection to AWS, so you'll need to put your AWS credentials into `~/.fog`, like so:
|
21
|
+
|
22
|
+
default:
|
23
|
+
aws_access_key_id: my_access_key
|
24
|
+
aws_secret_access_key: my_secret_access_key
|
25
|
+
public_key_path: ~/.ssh/id_rsa.pub
|
26
|
+
private_key_path: ~/.ssh/id_rsa
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Once the gem's bundled, run the following to create your temporary instance:
|
31
|
+
|
32
|
+
$ bundle exec deus_ex
|
33
|
+
|
34
|
+
The gem will tell you what it's doing, and will give you the git URL for your new deploy-fromable repo. Use that for your deploy,
|
35
|
+
then tear down your instance with
|
36
|
+
|
37
|
+
$ bundle exec deus_ex cleanup
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Provide a script to:
|
2
|
+
|
3
|
+
1. Provision an AWS micro instance
|
4
|
+
2. Set it up to host a public git repo
|
5
|
+
3. Push the current git repo to the AWS instance
|
6
|
+
1. Add a remote pointing to the AWS instance
|
7
|
+
2. Push to the remote
|
8
|
+
3. Removes the remote
|
9
|
+
4. Displays the public git URL for use in a deployment
|
10
|
+
5. Provides a means to deprovision the instance after the deploy is done
|
11
|
+
|
12
|
+
Additionally, there should be a Capistrano plugin that:
|
13
|
+
|
14
|
+
1. Does 1-3 above
|
15
|
+
2. Uses the public git URL for a live deploy
|
16
|
+
3. Automatically deprovisions the instance after the deploy is done
|
data/bin/deus_ex
ADDED
data/deus_ex.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'deus_ex/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "deus_ex"
|
8
|
+
spec.version = DeusEx::VERSION
|
9
|
+
spec.authors = ["Ben Scofield"]
|
10
|
+
spec.email = ["bscofield@gmail.com"]
|
11
|
+
spec.description = %q{Easily manage just-in-time EC2 git repos}
|
12
|
+
spec.summary = %q{Easily manage just-in-time EC2 git repos}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "fog", ">=1.15.0"
|
25
|
+
spec.add_dependency "net-ssh"
|
26
|
+
end
|
data/lib/deus_ex.rb
ADDED
data/lib/deus_ex/aws.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module DeusEx
|
4
|
+
class AWS
|
5
|
+
IMAGE_ID = 'ami-3679e75f'
|
6
|
+
DEPLOY_PROJECT = 'deus_ex_project'
|
7
|
+
REMOTE_USER = 'ubuntu'
|
8
|
+
GIT_REMOTE_NAME = 'deus-ex'
|
9
|
+
|
10
|
+
def self.setup
|
11
|
+
aws = new
|
12
|
+
aws.setup_connection
|
13
|
+
aws.setup_server
|
14
|
+
aws.setup_repository
|
15
|
+
aws.setup_git_remote
|
16
|
+
aws.announce_deploy_remote
|
17
|
+
rescue Exception => e
|
18
|
+
aws.log "error: #{e.inspect}"
|
19
|
+
aws.clean_up
|
20
|
+
raise e
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.cleanup
|
24
|
+
aws = new
|
25
|
+
aws.setup_connection
|
26
|
+
aws.clean_up
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_connection
|
30
|
+
@connection = Fog::Compute.new({
|
31
|
+
:provider => 'AWS'
|
32
|
+
})
|
33
|
+
log "connection complete"
|
34
|
+
end
|
35
|
+
|
36
|
+
def setup_server
|
37
|
+
log "creating server (this may take a couple of minutes)"
|
38
|
+
@server = @connection.servers.bootstrap({
|
39
|
+
:image_id => IMAGE_ID,
|
40
|
+
:username => REMOTE_USER
|
41
|
+
})
|
42
|
+
log "server created"
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_repository
|
46
|
+
log "initializing git repo"
|
47
|
+
@server.ssh([
|
48
|
+
"mkdir #{DEPLOY_PROJECT}.git",
|
49
|
+
"cd #{DEPLOY_PROJECT}.git && git init --bare"
|
50
|
+
])
|
51
|
+
|
52
|
+
log "git repo initialized"
|
53
|
+
end
|
54
|
+
|
55
|
+
def setup_git_remote
|
56
|
+
if system('git rev-parse')
|
57
|
+
log "adding git remote"
|
58
|
+
system "git remote add #{GIT_REMOTE_NAME} #{git_remote}"
|
59
|
+
|
60
|
+
log "pushing to remote"
|
61
|
+
system "git push #{GIT_REMOTE_NAME} master"
|
62
|
+
|
63
|
+
log "removing git remote"
|
64
|
+
system "git remote rm #{GIT_REMOTE_NAME}"
|
65
|
+
else
|
66
|
+
warn "not in a git repo"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def announce_deploy_remote
|
71
|
+
log "\nyou can now deploy from #{git_remote}\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
def clean_up
|
75
|
+
if @server
|
76
|
+
@server.destroy
|
77
|
+
else
|
78
|
+
@connection.servers.select {|s| s.image_id == IMAGE_ID}.map(&:destroy)
|
79
|
+
end
|
80
|
+
log "server destroyed"
|
81
|
+
end
|
82
|
+
|
83
|
+
def git_remote
|
84
|
+
"#{REMOTE_USER}@#{@server.dns_name}:#{DEPLOY_PROJECT}.git"
|
85
|
+
end
|
86
|
+
|
87
|
+
def log(message, level = :info, logger = Logger.new($stdout))
|
88
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
89
|
+
"[DEUS EX] #{msg}\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
logger.send(level, message)
|
93
|
+
end
|
94
|
+
|
95
|
+
def warn(message)
|
96
|
+
log message, :warn
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deus_ex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Scofield
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fog
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.15.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.15.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-ssh
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Easily manage just-in-time EC2 git repos
|
70
|
+
email:
|
71
|
+
- bscofield@gmail.com
|
72
|
+
executables:
|
73
|
+
- deus_ex
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- TODO.md
|
83
|
+
- bin/deus_ex
|
84
|
+
- deus_ex.gemspec
|
85
|
+
- lib/deus_ex.rb
|
86
|
+
- lib/deus_ex/aws.rb
|
87
|
+
- lib/deus_ex/version.rb
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.7
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Easily manage just-in-time EC2 git repos
|
112
|
+
test_files: []
|