capistrano-opsworks_deploy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17d1ee168ae7e6f436c01b861f1db5fb8f919c28
4
+ data.tar.gz: 20df8e590c1c04e988dc7e7a422c1f4108f21d58
5
+ SHA512:
6
+ metadata.gz: 6c133b50380d9bce840efcc0d6d60a130222efe4131e165cfbc1fd21d841dba656cb21b8d0bf02a58e0fbc86f4a1949a6637c42c80c299468e0dc22f8318c479
7
+ data.tar.gz: 594f7384aaa342e1a05de1b7802a08114cf09f3ce20d6a27e83a880812466efa088701d8669cc8f057b9fe928db9421a3b495cc11050bb4454029327aedc976e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-opsworks_deploy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Takeo Fujita
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,74 @@
1
+ # Capistrano::OpsworksDeploy
2
+
3
+ deploy app using AWS OpsWorks API with capistrano 3
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-opsworks_deploy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-opsworks_deploy
20
+
21
+ ## Usage
22
+
23
+ Add this line to Capfile
24
+
25
+ ```
26
+ require 'capistrano/opsworks_deploy'
27
+ ```
28
+
29
+ Set AWS credentials to environment variables
30
+
31
+ ```
32
+ export AWS_ACCESS_KEY_ID=...
33
+ export AWS_SECRET_ACCESS_KEY=...
34
+ ```
35
+
36
+ Write OpsWorks settings to deploy config file
37
+
38
+ ```ruby
39
+ set :opsworks_stack_id, '...'
40
+ set :opsworks_app_id, '...'
41
+ set :opsworks_instance_ids, ['...']
42
+ ```
43
+
44
+ Deploy app
45
+
46
+ ```
47
+ $ cap opsworks:deploy
48
+ ```
49
+
50
+ Deploy app with migration
51
+
52
+ ```
53
+ $ cap opsworks:deploy:migrate
54
+ ```
55
+
56
+ ### Executing recipes
57
+
58
+ You can also execute recipes by writing task
59
+
60
+ ```ruby
61
+ desc 'execute recipe foobar'
62
+ task :foobar do
63
+ set :opsworks_recipes, 'foobar'
64
+ invoke 'opsworks:execute_recipes'
65
+ end
66
+ ```
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it ( https://github.com/tkeo/capistrano-opsworks_deploy/fork )
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/opsworks_deploy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-opsworks_deploy"
8
+ spec.version = Capistrano::OpsworksDeploy::VERSION
9
+ spec.authors = ["Takeo Fujita"]
10
+ spec.email = ["takeofujita@gmail.com"]
11
+ spec.summary = %q{deploy application using OpsWorks API}
12
+ spec.homepage = "https://github.com/tkeo/capistrano-opsworks_deploy"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "capistrano", "~> 3.0"
21
+ spec.add_runtime_dependency "aws-sdk-core", "~> 2.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,4 @@
1
+ require 'capistrano'
2
+ require "capistrano/opsworks_deploy/version"
3
+
4
+ load File.expand_path('../tasks/opsworks.rake', __FILE__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module OpsworksDeploy
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,71 @@
1
+ require 'aws-sdk-core'
2
+
3
+ namespace :opsworks do
4
+ set :opsworks_region, 'us-east-1'
5
+
6
+ desc 'deploy using OpsWorks API'
7
+ task :deploy do
8
+ set :opsworks_command_name, 'deploy'
9
+ invoke 'opsworks:deploy:starting'
10
+ invoke 'opsworks:create_deployment'
11
+ invoke 'opsworks:wait_for_status_change'
12
+ invoke 'opsworks:deploy:finished'
13
+ end
14
+
15
+ task :execute_recipes do
16
+ set :opsworks_command_name, 'execute_recipes'
17
+ set :opsworks_command_args, { recipes: Array(fetch(:opsworks_recipes)) }
18
+ invoke 'opsworks:create_deployment'
19
+ invoke 'opsworks:wait_for_status_change'
20
+ end
21
+
22
+ namespace :deploy do
23
+ desc 'deploy and migrate using OpsWorks API'
24
+ task :migrate do
25
+ set :opsworks_command_name, 'deploy'
26
+ set :opsworks_command_args, { migrate: ['true'] }
27
+ invoke 'opsworks:deploy'
28
+ end
29
+
30
+ task :starting
31
+ task :finished
32
+ end
33
+
34
+ task :create_deployment do
35
+ options = {
36
+ stack_id: fetch(:opsworks_stack_id),
37
+ app_id: fetch(:opsworks_app_id),
38
+ instance_ids: fetch(:opsworks_instance_ids),
39
+ command: { name: fetch(:opsworks_command_name), args: fetch(:opsworks_command_args) },
40
+ }
41
+ if custom_json = fetch(:opsworks_custom_json, nil)
42
+ options[:custom_json] = custom_json
43
+ end
44
+ client = Aws::OpsWorks::Client.new(region: fetch(:opsworks_region))
45
+ response = client.create_deployment(options)
46
+ deployment_id = response.deployment_id
47
+ puts "start #{fetch(:opsworks_command_name)} (deployment_id: #{deployment_id})"
48
+ set :opsworks_deployment_id, deployment_id
49
+ end
50
+
51
+ task :wait_for_status_change do
52
+ client = Aws::OpsWorks::Client.new(region: fetch(:opsworks_region))
53
+ loop do
54
+ print '.'
55
+ sleep 30
56
+
57
+ response = client.describe_deployments(deployment_ids: [fetch(:opsworks_deployment_id)])
58
+ deployment = response.first.deployments.first
59
+
60
+ case deployment.status
61
+ when 'running'
62
+ next
63
+ when 'successful'
64
+ break
65
+ else
66
+ raise deployment.status
67
+ end
68
+ end
69
+ puts "\n#{fetch(:opsworks_command_name)} successfully finished."
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-opsworks_deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Takeo Fujita
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - takeofujita@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - capistrano-opsworks_deploy.gemspec
82
+ - lib/capistrano/opsworks_deploy.rb
83
+ - lib/capistrano/opsworks_deploy/version.rb
84
+ - lib/capistrano/tasks/opsworks.rake
85
+ homepage: https://github.com/tkeo/capistrano-opsworks_deploy
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: deploy application using OpsWorks API
109
+ test_files: []