capistrano-autoscale 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6a7f55b1621c59cfd055200381128a80f2c3806
4
+ data.tar.gz: b263d14c71124abdcbff45e8ccd2d586bba6a4c2
5
+ SHA512:
6
+ metadata.gz: 83f7bde01bdd2bf0b3e4f810424cdcd35e12eb5622d4666ae8cc7cb2991fafb042292fc4d8913cd33ace3465a10e17e3eb7056ed2804b3b92a0a8e781bbadab3
7
+ data.tar.gz: 0b7c1afc683a1f8d5ff56b9f29b65b8a37c75d0866d9d8ed77565335a789fd46bb5f76420605c38dbe1f9920ec5961a9b9a244e3740a15af12fa8b1af9b3e810
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
11
+ .DS_Store
12
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-autoscale.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Clinch Technology, Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Capistrano::Autoscale
2
+
3
+ This plugin was written to ease the deployment of Rails applications to AWS AutoScale groups.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```gem 'capistrano-autoscale'```
11
+
12
+ Add this statement to your Capfile:
13
+
14
+ ```require 'capistrano/autoscale```
15
+
16
+ ## Configuration
17
+
18
+ Below are the Capistrano configuration options with their defaults:
19
+
20
+ ```
21
+ set :aws_access_key_id, ENV['AWS_ACCESS_KEY_ID']
22
+ set :aws_secret_access_key, ENV['AWS_SECRET_ACCESS_KEY']
23
+ set :aws_region, ENV['AWS_REGION']
24
+ ```
25
+
26
+ And set the autoscale group:
27
+
28
+ ```
29
+ autoscale '<auto-scale-group-name>', user: '<deployment user>', roles: [<array of cap roles>]
30
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/autoscale/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-autoscale"
8
+ spec.version = Capistrano::Autoscale::VERSION
9
+ spec.authors = ["Damien Glancy"]
10
+ spec.email = ["support@clinch.io"]
11
+
12
+ spec.summary = %q{Capistrano plugin for deploying to AWS AutoScale groups.}
13
+ spec.description = %q{Deploys to all instances in a AWS AutoScale group.}
14
+ spec.homepage = "https://github.com/ClinchIO/capistrano-autoscale"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.13"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
24
+
25
+ spec.add_dependency 'aws-sdk', '~> 2'
26
+ spec.add_runtime_dependency 'capistrano', '~> 3.0', '> 3.0.0'
27
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws-sdk'
2
+ require 'capistrano/autoscale/aws/credentials'
3
+
4
+ module Capistrano
5
+ module Autoscale
6
+ module Aws
7
+ module AutoscalingGroup
8
+ include Capistrano::Autoscale::Aws::Credentials
9
+ include Capistrano::DSL
10
+
11
+ def autoscaling
12
+ @autoscaling ||= ::Aws::AutoScaling::Client.new(credentials)
13
+ end
14
+
15
+ def autoscale_group
16
+ @autoscale_group ||= autoscaling.describe_auto_scaling_groups({auto_scaling_group_names: [autoscale_group_name]}).auto_scaling_groups.first
17
+ end
18
+
19
+ def autoscale_group_name
20
+ fetch(:aws_autoscale_group)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ module Capistrano
2
+ module Autoscale
3
+ module Aws
4
+ module Credentials
5
+ include Capistrano::DSL
6
+
7
+ def credentials
8
+ credentials = {
9
+ access_key_id: fetch(:aws_access_key_id, ENV['AWS_ACCESS_KEY_ID']),
10
+ secret_access_key: fetch(:aws_secret_access_key, ENV['AWS_SECRET_ACCESS_KEY'])
11
+ }
12
+ credentials.merge! region: fetch(:aws_region) if fetch(:aws_region)
13
+ credentials
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ require 'aws-sdk'
2
+ require 'capistrano/autoscale/aws/credentials'
3
+
4
+ module Capistrano
5
+ module Autoscale
6
+ module Aws
7
+ module EC2
8
+ include Capistrano::Autoscale::Aws::Credentials
9
+
10
+ def ec2_client
11
+ @ec2_client ||= ::Aws::EC2::Client.new(credentials)
12
+ end
13
+
14
+ def ec2_instance(instance_id)
15
+ @ec2_instance ||= ::Aws::EC2::Instance.new(instance_id, client: ec2_client)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Autoscale
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require 'aws-sdk'
2
+ require 'capistrano/all'
3
+ require 'capistrano/dsl'
4
+
5
+ require 'capistrano/autoscale/version'
6
+ require 'capistrano/autoscale/aws/autoscaling_group'
7
+ require 'capistrano/autoscale/aws/ec2'
8
+
9
+ module Capistrano
10
+ module Autoscale
11
+ end
12
+ end
13
+
14
+ def autoscale(groupname, *args)
15
+ include Capistrano::DSL
16
+ include Capistrano::Autoscale::Aws::AutoscalingGroup
17
+ include Capistrano::Autoscale::Aws::EC2
18
+
19
+ set :aws_autoscale_group, groupname
20
+
21
+ instances = autoscale_group&.instances&.select do |instance|
22
+ instance.lifecycle_state == 'InService'
23
+ end
24
+
25
+ instances&.each do |instance|
26
+ hostname = ec2_instance(instance.instance_id).private_ip_address
27
+ p "Autoscale Deploying to: #{hostname}"
28
+ server(hostname, *args)
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-autoscale
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Damien Glancy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-07 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws-sdk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: capistrano
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ - - ">"
77
+ - !ruby/object:Gem::Version
78
+ version: 3.0.0
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '3.0'
86
+ - - ">"
87
+ - !ruby/object:Gem::Version
88
+ version: 3.0.0
89
+ description: Deploys to all instances in a AWS AutoScale group.
90
+ email:
91
+ - support@clinch.io
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - Gemfile
98
+ - LICENSE
99
+ - README.md
100
+ - Rakefile
101
+ - capistrano-autoscale.gemspec
102
+ - lib/capistrano/autoscale.rb
103
+ - lib/capistrano/autoscale/aws/autoscaling_group.rb
104
+ - lib/capistrano/autoscale/aws/credentials.rb
105
+ - lib/capistrano/autoscale/aws/ec2.rb
106
+ - lib/capistrano/autoscale/version.rb
107
+ homepage: https://github.com/ClinchIO/capistrano-autoscale
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.8
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Capistrano plugin for deploying to AWS AutoScale groups.
131
+ test_files: []