BibOpsworks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +6 -0
- data/BibOpsworks.gemspec +25 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +40 -0
- data/README.md +8 -0
- data/Rakefile +15 -0
- data/lib/bib/opsworks/composer.rb +19 -0
- data/lib/bib/opsworks/newrelic.rb +48 -0
- data/lib/bib/opsworks/version.rb +5 -0
- data/lib/bib/opsworks.rb +23 -0
- data/tests/bib_test.rb +12 -0
- data/tests/composer_test.rb +30 -0
- data/tests/newrelic_test.rb +27 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8cf0469a43058eb6c49e228f46a3e933eb446fd
|
4
|
+
data.tar.gz: dde5c0a724e69093f58afee1b47a8b5bb8ba39f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4d17a6464cbd335a3674beaf57dbff92ca91137a832d29ec9ef49246b2d9d384bf86a5dd847388251dff1a439b7d84bb076bdfb9b27c30f269c951eb06ae311
|
7
|
+
data.tar.gz: 727cecc23a1a8c764998b06ecb0dbfb939d1b2541a22adbcb8e65378da5cc5d553ed6a9f5c9c0b7e5bd1fde27884e4a1d1c209af22bb2177dc32be17813a9c1d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/BibOpsworks.gemspec
ADDED
@@ -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 'bib/opsworks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "BibOpsworks"
|
8
|
+
spec.version = Bib::Opsworks::VERSION
|
9
|
+
spec.authors = ["fh"]
|
10
|
+
spec.email = ["fh-gem@fholzhauer.de"]
|
11
|
+
spec.homepage = "https://github.com/fh/OpsworksEasybibGem"
|
12
|
+
spec.summary = "Tools wrapper for AWS Opsworks Deploys"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency 'json'
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0.8"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
end
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
Bib::Opsworks (0.0.1)
|
5
|
+
json
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coveralls (0.7.0)
|
11
|
+
multi_json (~> 1.3)
|
12
|
+
rest-client
|
13
|
+
simplecov (>= 0.7)
|
14
|
+
term-ansicolor
|
15
|
+
thor
|
16
|
+
json (1.7.7)
|
17
|
+
mime-types (2.0)
|
18
|
+
minitest (5.0.8)
|
19
|
+
multi_json (1.7.7)
|
20
|
+
rake (10.1.0)
|
21
|
+
rest-client (1.6.7)
|
22
|
+
mime-types (>= 1.16)
|
23
|
+
simplecov (0.7.1)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
simplecov-html (~> 0.7.1)
|
26
|
+
simplecov-html (0.7.1)
|
27
|
+
term-ansicolor (1.2.2)
|
28
|
+
tins (~> 0.8)
|
29
|
+
thor (0.18.1)
|
30
|
+
tins (0.12.0)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
Bib::Opsworks!
|
37
|
+
bundler (~> 1.3)
|
38
|
+
coveralls
|
39
|
+
minitest (~> 5.0.8)
|
40
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# bib::opsworks
|
2
|
+
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/easybiblabs/bib-opsworks.png?branch=master)](https://travis-ci.org/easybiblabs/bib-opswors)
|
5
|
+
|
6
|
+
## Huh?
|
7
|
+
|
8
|
+
This will soon become a gem we use with opsworks after\_restart.rb and before\_symlink.rb. See also [tills blogpost to speed up composer on opsworks](http://till.klampaeckel.de/blog/archives/202-Speeding-up-composer-on-AWS-OpsWorks.html)
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require "bundler/gem_tasks"
|
5
|
+
|
6
|
+
Encoding.default_external = Encoding::UTF_8
|
7
|
+
Encoding.default_internal = Encoding::UTF_8
|
8
|
+
|
9
|
+
task :test do
|
10
|
+
$LOAD_PATH.unshift('lib', 'tests')
|
11
|
+
Dir.glob('./tests/*_test.rb') do |f|
|
12
|
+
require f
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Bib
|
2
|
+
module Opsworks
|
3
|
+
class Composer
|
4
|
+
|
5
|
+
def copy_vendor(release_path, deploy_data)
|
6
|
+
app_current = ::File.expand_path("#{release_path}/../../current")
|
7
|
+
vendor_dir = "#{app_current}/vendor"
|
8
|
+
|
9
|
+
deploy_user = deploy_data['deploy_user']['user']
|
10
|
+
deploy_group = deploy_data['deploy_user']['group']
|
11
|
+
|
12
|
+
release_vendor = "#{release_path}/vendor"
|
13
|
+
|
14
|
+
::FileUtils.cp_r vendor_dir, release_vendor if ::File.exists?(vendor_dir)
|
15
|
+
::FileUtils.chown_R deploy_user, deploy_group, release_vendor if ::File.exists?(release_vendor)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
module Bib
|
3
|
+
module Opsworks
|
4
|
+
class Newrelic
|
5
|
+
|
6
|
+
def publish_deployment(app_name, deploy_data, newrelic_api_key)
|
7
|
+
|
8
|
+
newrelic_body = prepare_publishing_data(app_name, deploy_data)
|
9
|
+
|
10
|
+
newrelic_url = "https://rpm.newrelic.com/deployments.xml"
|
11
|
+
url = URI.parse(newrelic_url)
|
12
|
+
request = Net::HTTP::Post.new(url.request_uri)
|
13
|
+
request.add_field('X-License-Key', newrelic_api_key)
|
14
|
+
request.body = newrelic_body
|
15
|
+
resp = Net::HTTP.new(url.host, url.port).start do |http|
|
16
|
+
http.request(request)
|
17
|
+
end
|
18
|
+
|
19
|
+
case resp
|
20
|
+
when Net::HTTPOK
|
21
|
+
return true
|
22
|
+
else
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepare_publishing_data(app_name, deploy_data)
|
29
|
+
scm_revision = deploy_data["scm"]["revision"]
|
30
|
+
|
31
|
+
if deploy_data["deploying_user"].nil? or deploy_data["deploying_user"].empty?
|
32
|
+
deployment_user = "opsworks"
|
33
|
+
else
|
34
|
+
deployment_user = deploy_data["deploying_user"].split('/')[1]
|
35
|
+
end
|
36
|
+
|
37
|
+
newrelic_appid_body = "deployment[app_name]=#{app_name}"
|
38
|
+
newrelic_user_body = "deployment[user]=#{deployment_user}"
|
39
|
+
newrelic_revision_body = "deployment[revision]=#{scm_revision}"
|
40
|
+
|
41
|
+
newrelic_body = "#{newrelic_appid_body}&#{newrelic_user_body}&=#{newrelic_revision_body}"
|
42
|
+
|
43
|
+
return newrelic_body
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/bib/opsworks.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bib/opsworks/composer'
|
2
|
+
require 'bib/opsworks/newrelic'
|
3
|
+
require 'bib/opsworks/version'
|
4
|
+
|
5
|
+
class BibOpsworks
|
6
|
+
def initialize(deploy_data)
|
7
|
+
@deploy_data = deploy_data
|
8
|
+
end
|
9
|
+
|
10
|
+
def copy_composer(release_path)
|
11
|
+
composer = Bib::Opsworks::Composer.new()
|
12
|
+
composer.copy_vendor(release_path, @deploy_data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def newrelic_publish_deployment(app_name, newrelic_api_key)
|
16
|
+
newrelic = Bib::Opsworks::Newrelic.new()
|
17
|
+
newrelic.publish_deployment(app_name, @deploy_data, newrelic_api_key)
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
return Bib::Opsworks::VERSION
|
22
|
+
end
|
23
|
+
end
|
data/tests/bib_test.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
gem 'minitest'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'bib/opsworks/composer'
|
5
|
+
|
6
|
+
class ComposerTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@fixtures_path ||= Pathname.new(File.expand_path('../tmp-fixtures/', __FILE__)).tap{|path|
|
9
|
+
FileUtils.mkdir_p path.to_s
|
10
|
+
}
|
11
|
+
|
12
|
+
@release_path = Pathname.new(File.expand_path('releases/123/', @fixtures_path))
|
13
|
+
FileUtils.mkdir_p @release_path
|
14
|
+
FileUtils.mkdir_p Pathname.new(File.expand_path('current/vendor/some-lib', @fixtures_path))
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
FileUtils.rm_rf @fixtures_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_composer_copy
|
22
|
+
composervendor = Bib::Opsworks::Composer.new()
|
23
|
+
|
24
|
+
#do not use www-data, or the test will fail on systems without that user
|
25
|
+
deploydata = { 'deploy_user' => { 'user' => Process.uid, 'group' => Process.gid }}
|
26
|
+
|
27
|
+
composervendor.copy_vendor(@release_path, deploydata)
|
28
|
+
assert_equal(true,::File.exists?(File.expand_path('releases/123/vendor/some-lib',@fixtures_path)))
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
gem 'minitest'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'bib/opsworks/newrelic'
|
5
|
+
|
6
|
+
class NewrelicTest < Minitest::Test
|
7
|
+
|
8
|
+
def test_publish_deployment
|
9
|
+
newrelic = Bib::Opsworks::Newrelic.new()
|
10
|
+
|
11
|
+
deploy_data = { 'deploying_user' => 'arn:aws:iam::123456:user/gemtest', 'scm' => { 'revision' => 'rev1' } }
|
12
|
+
app_name = 'unittest'
|
13
|
+
|
14
|
+
result = newrelic.prepare_publishing_data(app_name, deploy_data)
|
15
|
+
assert_equal("deployment[app_name]=unittest&deployment[user]=gemtest&=deployment[revision]=rev1", result)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_publish_deployment_nouser
|
19
|
+
newrelic = Bib::Opsworks::Newrelic.new()
|
20
|
+
|
21
|
+
deploy_data = { 'scm' => { 'revision' => 'rev1' } }
|
22
|
+
app_name = 'unittest'
|
23
|
+
|
24
|
+
result = newrelic.prepare_publishing_data(app_name, deploy_data)
|
25
|
+
assert_equal("deployment[app_name]=unittest&deployment[user]=opsworks&=deployment[revision]=rev1", result)
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: BibOpsworks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 5.0.8
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 5.0.8
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- fh-gem@fholzhauer.de
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- BibOpsworks.gemspec
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/bib/opsworks.rb
|
98
|
+
- lib/bib/opsworks/composer.rb
|
99
|
+
- lib/bib/opsworks/newrelic.rb
|
100
|
+
- lib/bib/opsworks/version.rb
|
101
|
+
- tests/bib_test.rb
|
102
|
+
- tests/composer_test.rb
|
103
|
+
- tests/newrelic_test.rb
|
104
|
+
homepage: https://github.com/fh/OpsworksEasybibGem
|
105
|
+
licenses: []
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.1.10
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Tools wrapper for AWS Opsworks Deploys
|
127
|
+
test_files: []
|