opsworks_deployer 0.1.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.
- data/.document +5 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +20 -0
- data/README.md +34 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/lib/config/aws.yml.erb +3 -0
- data/lib/config/opsworks.yml.erb +4 -0
- data/lib/opsworks_deployer.rb +80 -0
- metadata +94 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.13)
|
5
|
+
actionpack (= 3.2.13)
|
6
|
+
mail (~> 2.5.3)
|
7
|
+
actionpack (3.2.13)
|
8
|
+
activemodel (= 3.2.13)
|
9
|
+
activesupport (= 3.2.13)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.4)
|
13
|
+
rack (~> 1.4.5)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.2.1)
|
17
|
+
activemodel (3.2.13)
|
18
|
+
activesupport (= 3.2.13)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.13)
|
21
|
+
activemodel (= 3.2.13)
|
22
|
+
activesupport (= 3.2.13)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.13)
|
26
|
+
activemodel (= 3.2.13)
|
27
|
+
activesupport (= 3.2.13)
|
28
|
+
activesupport (3.2.13)
|
29
|
+
i18n (= 0.6.1)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
arel (3.0.2)
|
32
|
+
aws-sdk (1.9.5)
|
33
|
+
json (~> 1.4)
|
34
|
+
nokogiri (>= 1.4.4)
|
35
|
+
uuidtools (~> 2.1)
|
36
|
+
builder (3.0.4)
|
37
|
+
erubis (2.7.0)
|
38
|
+
figaro (0.6.4)
|
39
|
+
bundler (~> 1.0)
|
40
|
+
rails (>= 3, < 5)
|
41
|
+
git (1.2.5)
|
42
|
+
hike (1.2.2)
|
43
|
+
i18n (0.6.1)
|
44
|
+
jeweler (1.8.4)
|
45
|
+
bundler (~> 1.0)
|
46
|
+
git (>= 1.2.5)
|
47
|
+
rake
|
48
|
+
rdoc
|
49
|
+
journey (1.0.4)
|
50
|
+
json (1.8.0)
|
51
|
+
mail (2.5.4)
|
52
|
+
mime-types (~> 1.16)
|
53
|
+
treetop (~> 1.4.8)
|
54
|
+
mime-types (1.23)
|
55
|
+
multi_json (1.7.3)
|
56
|
+
nokogiri (1.5.9)
|
57
|
+
polyglot (0.3.3)
|
58
|
+
rack (1.4.5)
|
59
|
+
rack-cache (1.2)
|
60
|
+
rack (>= 0.4)
|
61
|
+
rack-ssl (1.3.3)
|
62
|
+
rack
|
63
|
+
rack-test (0.6.2)
|
64
|
+
rack (>= 1.0)
|
65
|
+
rails (3.2.13)
|
66
|
+
actionmailer (= 3.2.13)
|
67
|
+
actionpack (= 3.2.13)
|
68
|
+
activerecord (= 3.2.13)
|
69
|
+
activeresource (= 3.2.13)
|
70
|
+
activesupport (= 3.2.13)
|
71
|
+
bundler (~> 1.0)
|
72
|
+
railties (= 3.2.13)
|
73
|
+
railties (3.2.13)
|
74
|
+
actionpack (= 3.2.13)
|
75
|
+
activesupport (= 3.2.13)
|
76
|
+
rack-ssl (~> 1.3.2)
|
77
|
+
rake (>= 0.8.7)
|
78
|
+
rdoc (~> 3.4)
|
79
|
+
thor (>= 0.14.6, < 2.0)
|
80
|
+
rake (10.0.4)
|
81
|
+
rdoc (3.12.2)
|
82
|
+
json (~> 1.4)
|
83
|
+
sprockets (2.2.2)
|
84
|
+
hike (~> 1.2)
|
85
|
+
multi_json (~> 1.0)
|
86
|
+
rack (~> 1.0)
|
87
|
+
tilt (~> 1.1, != 1.3.0)
|
88
|
+
thor (0.18.1)
|
89
|
+
tilt (1.4.1)
|
90
|
+
treetop (1.4.12)
|
91
|
+
polyglot
|
92
|
+
polyglot (>= 0.3.1)
|
93
|
+
tzinfo (0.3.37)
|
94
|
+
uuidtools (2.1.4)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
aws-sdk
|
101
|
+
figaro
|
102
|
+
jeweler (~> 1.8.4)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Luciano Issoe
|
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/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
opsworks-deployer
|
2
|
+
==================
|
3
|
+
|
4
|
+
Task to deploy via CLI on Amazon OpsWorks.
|
5
|
+
|
6
|
+
Please set these environment variables:
|
7
|
+
|
8
|
+
export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY>
|
9
|
+
|
10
|
+
export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_KEY>
|
11
|
+
|
12
|
+
export OPSWORKS_LAYER_ID=<YOUR_OPSWORKS_LAYER_ID>
|
13
|
+
|
14
|
+
export OPSWORKS_APP_ID=<YOUR_APP_ID>
|
15
|
+
|
16
|
+
on ~/.bash_profile or ~/.bashrc
|
17
|
+
|
18
|
+
|
19
|
+
Usage:
|
20
|
+
=====
|
21
|
+
|
22
|
+
Deploys an app with predefined branch/revision:
|
23
|
+
|
24
|
+
rake deploy
|
25
|
+
|
26
|
+
Deploys an app with specified branch/revision/tag:
|
27
|
+
|
28
|
+
rake deploy['<tag or revision or branch>']
|
29
|
+
|
30
|
+
|
31
|
+
Deploy procedure:
|
32
|
+
================
|
33
|
+
|
34
|
+
It tries to deploy each AZ on each region one at a time.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
gem.name = "opsworks_deployer"
|
17
|
+
gem.homepage = "https://github.com/miagao/opsworks_deployer"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = "Task to deploy via CLI on Amazon OpsWorks."
|
20
|
+
gem.description = "Task to deploy via CLI on Amazon OpsWorks."
|
21
|
+
gem.email = "miagao@gmail.com"
|
22
|
+
gem.authors = [ "Luciano Issoe", "Flavio Mori" ]
|
23
|
+
gem.files.include 'lib/config/aws.yml.erb'
|
24
|
+
gem.files.include 'lib/config/opsworks.yml.erb'
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class OpsworksDeployer < Rails::Railtie
|
2
|
+
|
3
|
+
rake_tasks do
|
4
|
+
# Authenticate to AWS
|
5
|
+
task :confirm do
|
6
|
+
confirm_token = rand(36**6).to_s(36)
|
7
|
+
STDOUT.puts "Confirm deploy? Enter '#{confirm_token}' to confirm:"
|
8
|
+
input = STDIN.gets.chomp
|
9
|
+
raise "Aborting [ACTION]. You entered #{input}" unless input == confirm_token
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Deploy the app to the LIVE environment"
|
13
|
+
task :deploy,[:tag] => :confirm do |t , args|
|
14
|
+
config_file = File.read(File.join( File.dirname(__FILE__), 'config', 'aws.yml.erb'))
|
15
|
+
AWS_CONFIG = YAML.load(ERB.new(config_file).result)['production']
|
16
|
+
puts AWS_CONFIG
|
17
|
+
AWS.config(AWS_CONFIG)
|
18
|
+
client = AWS::OpsWorks.new.client
|
19
|
+
tag = args.tag
|
20
|
+
config_file2 = File.read(File.join( File.dirname(__FILE__), 'config', 'opsworks.yml.erb'))
|
21
|
+
regions = YAML.load(ERB.new(config_file2).result)['production']
|
22
|
+
|
23
|
+
|
24
|
+
deploy_options = {}
|
25
|
+
deploy_options[:command] = {name:'deploy'}
|
26
|
+
|
27
|
+
azs = ['us-east-1a','us-east-1b','us-east-1c','us-east-1d']
|
28
|
+
|
29
|
+
azs.each do |zone|
|
30
|
+
regions.each do |region, options|
|
31
|
+
p options
|
32
|
+
deploy_options[:instance_ids] = []
|
33
|
+
deploy_options[:app_id] = options['app_id']
|
34
|
+
deploy_options[:comment] = "rake deploy from '#{Socket.gethostname}'"
|
35
|
+
instances = client.describe_instances({layer_id: options['layer_id']})
|
36
|
+
next if instances.nil? || instances.empty?
|
37
|
+
|
38
|
+
if tag
|
39
|
+
app_options = {}
|
40
|
+
app_options[:app_id] = options['app_id']
|
41
|
+
app_revision = {}
|
42
|
+
app_revision[:revision] = tag
|
43
|
+
app_options[:app_source] = app_revision
|
44
|
+
client.update_app( app_options )
|
45
|
+
tag = false
|
46
|
+
end
|
47
|
+
# Capture the details for each 'online' instance
|
48
|
+
instances[:instances].each do |instance|
|
49
|
+
puts instance
|
50
|
+
if 'online' == instance[:status] && zone == instance[:availability_zone]
|
51
|
+
deploy_options[:instance_ids] << instance[:instance_id]
|
52
|
+
deploy_options[:stack_id] = instance[:stack_id]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "Deploying to #{deploy_options[:instance_ids].count} instances in the #{region.upcase} region... in Zone #{zone.upcase}"
|
57
|
+
deploy_id = client.create_deployment deploy_options
|
58
|
+
|
59
|
+
|
60
|
+
deployment_options = {}
|
61
|
+
deployment_options[:deployment_ids] = []
|
62
|
+
deployment_options[:deployment_ids] << deploy_id.deployment_id
|
63
|
+
|
64
|
+
begin
|
65
|
+
sleep 5
|
66
|
+
deployments = client.describe_deployments deployment_options
|
67
|
+
next if deployments.nil? || deployments.empty?
|
68
|
+
response = "running"
|
69
|
+
deployments[:deployments].each do |deploy|
|
70
|
+
response = deploy[:status]
|
71
|
+
end
|
72
|
+
puts "...#{response}..."
|
73
|
+
end while response == "running"
|
74
|
+
sleep 5
|
75
|
+
puts "...DONE!"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opsworks_deployer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luciano Issoe
|
9
|
+
- Flavio Mori
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: aws-sdk
|
17
|
+
requirement: &70347677396240 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70347677396240
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: figaro
|
28
|
+
requirement: &70347677395580 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70347677395580
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jeweler
|
39
|
+
requirement: &70347677395080 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.8.4
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *70347677395080
|
48
|
+
description: Task to deploy via CLI on Amazon OpsWorks.
|
49
|
+
email: miagao@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
files:
|
56
|
+
- .document
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- lib/config/aws.yml.erb
|
64
|
+
- lib/config/opsworks.yml.erb
|
65
|
+
- lib/opsworks_deployer.rb
|
66
|
+
homepage: https://github.com/miagao/opsworks_deployer
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: 2637289232212668267
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.10
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Task to deploy via CLI on Amazon OpsWorks.
|
94
|
+
test_files: []
|