kraken 0.0.7 → 0.0.9

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmI4M2IxMDQzOGVkYjZhYjg3YmRiNjQyZDE5MjhkNTNhNGE0MGU5MA==
5
+ data.tar.gz: !binary |-
6
+ Y2JmNzU4ZDFmNmViNjA2N2Y0YmVhZjgwYTJlYmE0NmI4ZDcwMGE0NA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzY1MGJkOGNkNmFiZmNiYzc3ZGNkMTZkZDdiZTRmZmZlMTRhZDgxNmQyMjBj
10
+ NWMxZTdmYTNlMDhhMDZjYjFjYmYxODdhMTk5MDEwYTFjNmNmZDNjYjVkMDJm
11
+ MzhlODQ2MDBkMGVkYTlkZGFhN2ZiMWNkYjYxMmJhNmJmNmMwZTI=
12
+ data.tar.gz: !binary |-
13
+ MGZhODY3YTZhOGZiNDFkYWM3NWRiZTJkMTg5OTJlNzlhMjliM2IzZGQzOTMz
14
+ NjQ0NGQ0MjZjNmYzNWEwZWM0OTM4ZmQ1OTlmZWQwMTk4NDQyMWZmMGNjZjdh
15
+ Mzk5NDQ2ZDVlMzk5ODExODJhMGZkYWY4NDM0MjRlZGM0ZTI1NGE=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'guard-rspec'
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
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.
@@ -0,0 +1,31 @@
1
+ # Kraken
2
+
3
+ Test driven configuration and deploys across multiple environments and servers.
4
+
5
+ ![Smaller icon](http://blogs.ups.edu/studentlife/files/2011/01/kraken.jpg "Kraken")
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'kraken'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kraken
20
+
21
+ ## Usage
22
+
23
+ Inherit from Kraken and you shall receive all the power you need.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
@@ -0,0 +1,25 @@
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("\n")
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
+
15
+ gem.name = 'kraken'
16
+ gem.require_paths = [ 'lib' ]
17
+ gem.version = Kraken::VERSION
18
+
19
+ gem.add_dependency 'net-ssh'
20
+ gem.add_dependency 'chef'
21
+
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'webmock'
25
+ end
@@ -0,0 +1,65 @@
1
+ require 'chef/knife'
2
+
3
+ class Chef
4
+ class Knife
5
+ class Deploy < Knife
6
+ deps do
7
+ require 'chef/search/query'
8
+ end
9
+
10
+ banner 'knife deploy APPLICATION ENVIRONMENT (options)'
11
+
12
+ option :application, short: '-a APPLICATION', long: '--application', description: 'The application to deploy.'
13
+ option :environment, short: '-e ENVIRONMENT', long: '--environment', description: 'The environment to deploy.', default: 'rc'
14
+
15
+ def run
16
+ nodes.each do |node|
17
+ Chef::Log.debug "Enabling deploy for #{application} on #{environment}."
18
+ chef node
19
+ end
20
+ end
21
+
22
+ private
23
+ def application
24
+ config[:application]
25
+ end
26
+
27
+ def environment
28
+ config[:environment]
29
+ end
30
+
31
+ def nodes
32
+ q = Chef::Search::Query.new
33
+ params = "chef_environment:#{environment} AND tags:#{application}"
34
+ query = URI.escape(params, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
35
+
36
+ nodes = []
37
+ q.search 'node', query do |node|
38
+ Chef::Log.debug "Adding node #{node.inspect}."
39
+ nodes << node
40
+ end
41
+ nodes
42
+ end
43
+
44
+ def command
45
+ 'sudo chef-client'
46
+ end
47
+
48
+ def user
49
+ 'config'
50
+ end
51
+
52
+ def chef(node)
53
+ ssh = Chef::Knife::Ssh.new
54
+ ssh.config[:node_name] = node.name
55
+ ssh.config[:ssh_user] = user
56
+ ssh.config[:attribute] = 'ipaddress'
57
+ ssh.config[:manual] = false
58
+ ssh.name_args = [ "name:#{node.name}", command ]
59
+ ssh.run
60
+
61
+ Chef::Log.debug "Kraken deployed to #{node.name}!"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Kraken
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kraken::Bestower, 'Knife' do
4
+ it { subject.should be_kind_of Chef::Knife }
5
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'kraken'
3
+
4
+ RSpec.configure do
5
+
6
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kraken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Umang Chouhan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-13 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: net-ssh
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: chef
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: webmock
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -99,38 +88,39 @@ executables: []
99
88
  extensions: []
100
89
  extra_rdoc_files: []
101
90
  files:
102
- - lib/kraken.rb
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - kraken.gemspec
97
+ - lib/chef/knife/deploy.rb
103
98
  - lib/kraken/version.rb
104
- - lib/kraken/bestower.rb
99
+ - spec/lib/kraken_spec.rb
100
+ - spec/spec_helper.rb
105
101
  homepage: http://github.com/optimis/kraken
106
102
  licenses: []
103
+ metadata: {}
107
104
  post_install_message:
108
105
  rdoc_options: []
109
106
  require_paths:
110
107
  - lib
111
- - lib/kraken
112
108
  required_ruby_version: !ruby/object:Gem::Requirement
113
- none: false
114
109
  requirements:
115
110
  - - ! '>='
116
111
  - !ruby/object:Gem::Version
117
112
  version: '0'
118
- segments:
119
- - 0
120
- hash: 2295443579256165516
121
113
  required_rubygems_version: !ruby/object:Gem::Requirement
122
- none: false
123
114
  requirements:
124
115
  - - ! '>='
125
116
  - !ruby/object:Gem::Version
126
117
  version: '0'
127
- segments:
128
- - 0
129
- hash: 2295443579256165516
130
118
  requirements: []
131
119
  rubyforge_project:
132
- rubygems_version: 1.8.21
120
+ rubygems_version: 2.2.1
133
121
  signing_key:
134
- specification_version: 3
122
+ specification_version: 4
135
123
  summary: Use chefs knife to automate complicated deploys.
136
- test_files: []
124
+ test_files:
125
+ - spec/lib/kraken_spec.rb
126
+ - spec/spec_helper.rb
@@ -1,8 +0,0 @@
1
- require 'net/ssh'
2
- require 'net/ssh/multi'
3
-
4
- require 'chef'
5
- require 'chef/knife'
6
-
7
- require 'kraken/version'
8
- require 'kraken/bestower'
@@ -1,71 +0,0 @@
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
- private
10
- def environment
11
- config[:environment] || 'RC'
12
- end
13
-
14
- def nodes(tag)
15
- query = Chef::Search::Query.new
16
-
17
- nodes = []
18
- query.search 'node', "chef_environment:#{environment} AND tags:#{tag}" do |node|
19
- nodes << node
20
- end
21
- nodes
22
- end
23
-
24
- def rc?
25
- environment == 'RC'
26
- end
27
-
28
- def user
29
- rc? ? 'ec2-user' : 'config'
30
- end
31
-
32
- def command
33
- 'sudo chef-client'
34
- end
35
-
36
- def chef(node, recipe)
37
- ssh = Chef::Knife::Ssh.new
38
- ssh.config[:node_name] = node.name
39
- ssh.config[:ssh_user] = user
40
-
41
- if rc?
42
- ssh.config[:attribute] = 'ec2.public_hostname'
43
- ssh.config[:identity_file] = '~/.ssh/aws'
44
- else
45
- ssh.config[:attribute] = 'ipaddress'
46
- end
47
-
48
- ssh.name_args = [ "name:#{node.name}", command ]
49
- ssh.run
50
-
51
- node.run_list.remove "recipe[#{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
-
61
- run_list = node.run_list
62
-
63
- node.run_list << recipe
64
- node.save
65
-
66
- Chef::Log.debug "Running chef client on #{node.name}."
67
- chef node, recipe
68
- end
69
- end
70
- end
71
- end