infopark_opsworks_helpers 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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/infopark_opsworks_helpers.gemspec +23 -0
- data/lib/infopark_opsworks_helpers.rb +9 -0
- data/lib/infopark_opsworks_helpers/deploy.rb +42 -0
- data/lib/infopark_opsworks_helpers/railtie.rb +10 -0
- data/lib/infopark_opsworks_helpers/version.rb +5 -0
- data/lib/tasks/infopark_opsworks_helpers.rake +26 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1b1dce08c2dd401a860a039049671c8dddb31e7
|
4
|
+
data.tar.gz: 5e3befbb86b172cd02c795465314a5e38f35868c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 910d001fe4422948ed1ee763c9b40eee88c8d9b973de378ce61e1ea2b20db321a1356e315130513c0082cba8881eb675d3cb61a6a8de845f1be669ddc3aa5da4
|
7
|
+
data.tar.gz: 49596d2103621162ed53a20fa232aed7a6e444bf5db42fb6f9a10f01dee596c7d48083fd0380187a2ad45499be31b90f2ec69ba6c699bceef80c3505104eb99e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Infopark OpsworksHelpers
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'infopark_opsworks_helpers'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install infopark_opsworks_little_helpers
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### General
|
22
|
+
|
23
|
+
The tasks defined in this gem expect the following ENV variables to be set:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
AWS_ACCESS_KEY_ID
|
27
|
+
AWS_SECRET_ACCESS_KEY
|
28
|
+
AWS_OPSWORKS_STACK_ID
|
29
|
+
AWS_OPSWORKS_APP_ID
|
30
|
+
```
|
31
|
+
|
32
|
+
### Rails
|
33
|
+
|
34
|
+
After adding to the Gemfile you can see the available rake tasks with
|
35
|
+
|
36
|
+
$ bundle exec rake -T opsworks
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/infopark/infopark_opsworks_little_helpers.
|
47
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "infopark_opsworks_little_helpers"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'infopark_opsworks_helpers/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "infopark_opsworks_helpers"
|
8
|
+
spec.version = Infopark::OpsworksHelpers::VERSION
|
9
|
+
spec.authors = ["Ben Zimmer"]
|
10
|
+
spec.email = ["benjamin.zimmer@infopark.de"]
|
11
|
+
|
12
|
+
spec.summary = %q{Provides little helper functions for managing AWS OpsWorks stacks.}
|
13
|
+
spec.homepage = "https://github.com/infopark/opsworks-helpers"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
spec.add_development_dependency "rspec"
|
21
|
+
|
22
|
+
spec.add_dependency "aws-sdk", "~>2"
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
|
3
|
+
module Infopark::OpsworksHelpers
|
4
|
+
class Deploy
|
5
|
+
|
6
|
+
def deploy(command, comment='Run via in-app rake task')
|
7
|
+
client.create_deployment(
|
8
|
+
stack_id: opsworks_stack_id,
|
9
|
+
app_id: opsworks_app_id,
|
10
|
+
command: command,
|
11
|
+
comment: comment
|
12
|
+
).deployment_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def display_deployment_result(command_name, deployment_id)
|
16
|
+
begin
|
17
|
+
puts "[#{deployment_id}] Waiting for command '#{command_name}' to finish..."
|
18
|
+
client.wait_until(:deployment_successful, deployment_ids: [deployment_id])
|
19
|
+
puts "[#{deployment_id}] Command '#{command_name}' successful."
|
20
|
+
true
|
21
|
+
rescue ::Aws::Waiters::Errors::WaiterFailed => e
|
22
|
+
puts "[#{deployment_id}] Command '#{command_name}' failed. Message: #{e.message}"
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def client
|
30
|
+
@client ||= Aws::OpsWorks::Client.new(region: 'us-east-1')
|
31
|
+
end
|
32
|
+
|
33
|
+
def opsworks_stack_id
|
34
|
+
ENV['AWS_OPSWORKS_STACK_ID'] || fail('Please provide AWS_OPSWORKS_STACK_ID in env.')
|
35
|
+
end
|
36
|
+
|
37
|
+
def opsworks_app_id
|
38
|
+
ENV['AWS_OPSWORKS_APP_ID'] || fail('Please provide AWS_OPSWORKS_APP_ID in env.')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
namespace 'opsworks' do
|
2
|
+
|
3
|
+
client = Infopark::OpsworksHelpers::Deploy.new
|
4
|
+
|
5
|
+
desc 'Deploy application to stack (and migrate database)'
|
6
|
+
task :deploy => :environment do
|
7
|
+
command_name = 'deploy'
|
8
|
+
deployment_id = client.deploy({
|
9
|
+
name: command_name,
|
10
|
+
args: { migrate: ['true'] }
|
11
|
+
})
|
12
|
+
|
13
|
+
client.display_deployment_result(command_name, deployment_id)
|
14
|
+
end
|
15
|
+
|
16
|
+
%w(rollback restart start stop configure setup).each do |command_name|
|
17
|
+
desc "Run command '#{command_name}' on OpsWorks"
|
18
|
+
task command_name => :environment do
|
19
|
+
deployment_id = client.deploy({name: command_name})
|
20
|
+
|
21
|
+
client.display_deployment_result(command_name, deployment_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: infopark_opsworks_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Zimmer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-18 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '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
|
+
description:
|
70
|
+
email:
|
71
|
+
- benjamin.zimmer@infopark.de
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- infopark_opsworks_helpers.gemspec
|
85
|
+
- lib/infopark_opsworks_helpers.rb
|
86
|
+
- lib/infopark_opsworks_helpers/deploy.rb
|
87
|
+
- lib/infopark_opsworks_helpers/railtie.rb
|
88
|
+
- lib/infopark_opsworks_helpers/version.rb
|
89
|
+
- lib/tasks/infopark_opsworks_helpers.rake
|
90
|
+
homepage: https://github.com/infopark/opsworks-helpers
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.5.1
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Provides little helper functions for managing AWS OpsWorks stacks.
|
113
|
+
test_files: []
|