kraken 0.0.1 → 0.0.2
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/lib/kraken.rb +3 -69
- data/lib/kraken/bestower.rb +68 -0
- data/lib/kraken/version.rb +1 -1
- metadata +52 -24
- data/.gitignore +0 -17
- data/Gemfile +0 -7
- data/LICENSE +0 -22
- data/README.md +0 -29
- data/Rakefile +0 -2
- data/kraken.gemspec +0 -23
- data/spec/lib/kraken_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -6
data/lib/kraken.rb
CHANGED
@@ -1,74 +1,8 @@
|
|
1
|
-
require 'kraken/version'
|
2
1
|
require 'net/ssh'
|
3
2
|
require 'net/ssh/multi'
|
3
|
+
|
4
4
|
require 'chef'
|
5
5
|
require 'chef/knife'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
deps do
|
10
|
-
require 'chef/search/query'
|
11
|
-
|
12
|
-
Chef::Knife::Ssh.load_deps
|
13
|
-
end
|
14
|
-
|
15
|
-
option :environment, :short => '-e ENVIRONMENT', :long => '--environment', :description => 'The environment to slice.'
|
16
|
-
|
17
|
-
private
|
18
|
-
def environment
|
19
|
-
config[:environment] || 'RC'
|
20
|
-
end
|
21
|
-
|
22
|
-
def nodes(tag)
|
23
|
-
query = Chef::Search::Query.new
|
24
|
-
|
25
|
-
nodes = []
|
26
|
-
query.search 'node', "chef_environment:#{environment} AND tags:#{tag}" do |node|
|
27
|
-
nodes << node
|
28
|
-
end
|
29
|
-
nodes
|
30
|
-
end
|
31
|
-
|
32
|
-
def rc?
|
33
|
-
environment == 'RC'
|
34
|
-
end
|
35
|
-
|
36
|
-
def user
|
37
|
-
rc? ? 'ec2-user' : 'config'
|
38
|
-
end
|
39
|
-
|
40
|
-
def command
|
41
|
-
'sudo chef-client'
|
42
|
-
end
|
43
|
-
|
44
|
-
def chef(node, recipe)
|
45
|
-
ssh = Chef::Knife::Ssh.new
|
46
|
-
ssh.config[:node_name] = node.name
|
47
|
-
ssh.config[:ssh_user] = user
|
48
|
-
|
49
|
-
if rc?
|
50
|
-
ssh.config[:attribute] = 'ec2.public_hostname'
|
51
|
-
ssh.config[:identity_file] = '~/.ssh/aws' if rc?
|
52
|
-
end
|
53
|
-
|
54
|
-
ssh.name_args = [ "name:#{node.name}", command ]
|
55
|
-
ssh.run
|
56
|
-
|
57
|
-
node.run_list.remove recipe
|
58
|
-
node.save
|
59
|
-
|
60
|
-
Chef::Log.debug "Kraken deployed #{recipe} on #{node.name}!"
|
61
|
-
end
|
62
|
-
|
63
|
-
def perform(application, recipe)
|
64
|
-
nodes(application).each do |node|
|
65
|
-
Chef::Log.debug "Adding #{recipe} to #{node.name}'s run list."
|
66
|
-
node.run_list << recipe
|
67
|
-
node.save
|
68
|
-
|
69
|
-
Chef::Log.debug "Running chef client on #{node.name}."
|
70
|
-
chef node, recipe
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
7
|
+
require 'kraken/version'
|
8
|
+
require 'kraken/bestower'
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Kraken
|
2
|
+
class Bestower < Chef::Knife
|
3
|
+
deps do
|
4
|
+
require 'chef/search/query'
|
5
|
+
|
6
|
+
Chef::Knife::Ssh.load_deps
|
7
|
+
end
|
8
|
+
|
9
|
+
option :environment, :short => '-e ENVIRONMENT', :long => '--environment', :description => 'The environment to slice.'
|
10
|
+
|
11
|
+
private
|
12
|
+
def environment
|
13
|
+
config[:environment] || 'RC'
|
14
|
+
end
|
15
|
+
|
16
|
+
def nodes(tag)
|
17
|
+
query = Chef::Search::Query.new
|
18
|
+
|
19
|
+
nodes = []
|
20
|
+
query.search 'node', "chef_environment:#{environment} AND tags:#{tag}" do |node|
|
21
|
+
nodes << node
|
22
|
+
end
|
23
|
+
nodes
|
24
|
+
end
|
25
|
+
|
26
|
+
def rc?
|
27
|
+
environment == 'RC'
|
28
|
+
end
|
29
|
+
|
30
|
+
def user
|
31
|
+
rc? ? 'ec2-user' : 'config'
|
32
|
+
end
|
33
|
+
|
34
|
+
def command
|
35
|
+
'sudo chef-client'
|
36
|
+
end
|
37
|
+
|
38
|
+
def chef(node, recipe)
|
39
|
+
ssh = Chef::Knife::Ssh.new
|
40
|
+
ssh.config[:node_name] = node.name
|
41
|
+
ssh.config[:ssh_user] = user
|
42
|
+
|
43
|
+
if rc?
|
44
|
+
ssh.config[:attribute] = 'ec2.public_hostname'
|
45
|
+
ssh.config[:identity_file] = '~/.ssh/aws' if rc?
|
46
|
+
end
|
47
|
+
|
48
|
+
ssh.name_args = [ "name:#{node.name}", command ]
|
49
|
+
ssh.run
|
50
|
+
|
51
|
+
node.run_list.remove recipe
|
52
|
+
node.save
|
53
|
+
|
54
|
+
Chef::Log.debug "Kraken deployed #{recipe} on #{node.name}!"
|
55
|
+
end
|
56
|
+
|
57
|
+
def perform(application, recipe)
|
58
|
+
nodes(application).each do |node|
|
59
|
+
Chef::Log.debug "Adding #{recipe} to #{node.name}'s run list."
|
60
|
+
node.run_list << recipe
|
61
|
+
node.save
|
62
|
+
|
63
|
+
Chef::Log.debug "Running chef client on #{node.name}."
|
64
|
+
chef node, recipe
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/kraken/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kraken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: chef
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,28 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
58
94
|
description: Test driven configuration and deploys across multiple environments and
|
59
95
|
servers.
|
60
96
|
email:
|
@@ -63,22 +99,16 @@ executables: []
|
|
63
99
|
extensions: []
|
64
100
|
extra_rdoc_files: []
|
65
101
|
files:
|
66
|
-
- .gitignore
|
67
|
-
- Gemfile
|
68
|
-
- LICENSE
|
69
|
-
- README.md
|
70
|
-
- Rakefile
|
71
|
-
- kraken.gemspec
|
72
102
|
- lib/kraken.rb
|
73
103
|
- lib/kraken/version.rb
|
74
|
-
-
|
75
|
-
- spec/spec_helper.rb
|
104
|
+
- lib/kraken/bestower.rb
|
76
105
|
homepage: http://github.com/optimis/kraken
|
77
106
|
licenses: []
|
78
107
|
post_install_message:
|
79
108
|
rdoc_options: []
|
80
109
|
require_paths:
|
81
110
|
- lib
|
111
|
+
- lib/kraken
|
82
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
@@ -87,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
117
|
version: '0'
|
88
118
|
segments:
|
89
119
|
- 0
|
90
|
-
hash: -
|
120
|
+
hash: -1760697516696187092
|
91
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
122
|
none: false
|
93
123
|
requirements:
|
@@ -96,13 +126,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
126
|
version: '0'
|
97
127
|
segments:
|
98
128
|
- 0
|
99
|
-
hash: -
|
129
|
+
hash: -1760697516696187092
|
100
130
|
requirements: []
|
101
131
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.8.
|
132
|
+
rubygems_version: 1.8.21
|
103
133
|
signing_key:
|
104
134
|
specification_version: 3
|
105
135
|
summary: Use chefs knife to automate complicated deploys.
|
106
|
-
test_files:
|
107
|
-
- spec/lib/kraken_spec.rb
|
108
|
-
- spec/spec_helper.rb
|
136
|
+
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Umang Chouhan
|
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
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Kraken
|
2
|
-
|
3
|
-
Test driven configuration and deploys across multiple environments and servers.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'kraken'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install kraken
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
Inherit from Kraken and you shall receive all the power you need.
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
data/kraken.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/kraken/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [ 'Umang Chouhan' ]
|
6
|
-
gem.email = [ 'uchouhan@optimiscorp.com' ]
|
7
|
-
gem.description = 'Test driven configuration and deploys across multiple environments and servers.'
|
8
|
-
gem.summary = 'Use chefs knife to automate complicated deploys.'
|
9
|
-
gem.homepage = 'http://github.com/optimis/kraken'
|
10
|
-
|
11
|
-
gem.files = `git ls-files`.split($\)
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map { |file| File.basename(file) }
|
13
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name = 'kraken'
|
15
|
-
gem.require_paths = [ 'lib' ]
|
16
|
-
gem.version = Kraken::VERSION
|
17
|
-
|
18
|
-
gem.add_dependency 'net-ssh'
|
19
|
-
gem.add_dependency 'chef'
|
20
|
-
|
21
|
-
gem.add_development_dependency 'rake'
|
22
|
-
gem.add_development_dependency 'rspec'
|
23
|
-
end
|
data/spec/lib/kraken_spec.rb
DELETED