solokit 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ree-1.8.7-2011.03@solokit --create
1
+ rvm ruby-1.9.3-p194@solokit --create
data/CHANGELOG CHANGED
@@ -1,4 +1,4 @@
1
- 0.1.14
1
+ 0.1.15
2
2
 
3
3
  Fixed deprication messages and some other things.
4
4
 
data/Gemfile.lock CHANGED
@@ -1,21 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solokit (0.1.14)
4
+ solokit (0.1.15)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- activesupport (3.2.11)
11
- i18n (~> 0.6)
12
- multi_json (~> 1.0)
13
- i18n (0.6.1)
14
- multi_json (1.5.0)
10
+ activesupport (4.0.2)
11
+ i18n (~> 0.6, >= 0.6.4)
12
+ minitest (~> 4.2)
13
+ multi_json (~> 1.3)
14
+ thread_safe (~> 0.1)
15
+ tzinfo (~> 0.3.37)
16
+ atomic (1.1.14)
17
+ diff-lcs (1.2.5)
18
+ i18n (0.6.9)
19
+ minitest (4.7.5)
20
+ multi_json (1.8.4)
21
+ rspec (2.14.1)
22
+ rspec-core (~> 2.14.0)
23
+ rspec-expectations (~> 2.14.0)
24
+ rspec-mocks (~> 2.14.0)
25
+ rspec-core (2.14.7)
26
+ rspec-expectations (2.14.5)
27
+ diff-lcs (>= 1.1.3, < 2.0)
28
+ rspec-mocks (2.14.5)
29
+ thread_safe (0.1.3)
30
+ atomic
31
+ tzinfo (0.3.38)
15
32
 
16
33
  PLATFORMS
17
34
  ruby
18
35
 
19
36
  DEPENDENCIES
20
37
  bundler
38
+ rspec
21
39
  solokit!
data/Rakefile CHANGED
@@ -2,3 +2,7 @@ require 'bundler'
2
2
 
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
+ task :default do
6
+ system("rspec") || exit(1)
7
+ end
8
+
data/lib/chef.rb CHANGED
@@ -1,17 +1,20 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'ssh.rb'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'ssh_login.rb'))
2
2
 
3
3
  module Solokit
4
4
  class Chef
5
- def initialize(ip, name, env, debug_ssh, user = 'root')
5
+ def initialize(ip, name, env, debug_ssh, user = 'root', vm = nil)
6
6
  @ip, @name, @env = ip, name, env
7
- @ssh = SSH.new(ip, user, debug_ssh)
7
+
8
+ # TODO: remove the assumption that chef packages are uploaded by ssh
9
+ # in classes using this class.
10
+ @vm = vm || SshLogin.new(ip, user, debug_ssh)
8
11
  end
9
12
 
10
13
  def install(use_old_config = false)
11
14
  return true if installed?
12
15
  puts "#{@name} (#{@env}): Installing chef..."
13
16
  dpkg_options = use_old_config ? '--force-confold' : '--force-confnew'
14
- @ssh.run(%{export DEBIAN_FRONTEND=noninteractive; apt-get update && apt-get upgrade -y -o Dpkg::Options::="#{dpkg_options}" && apt-get install -o Dpkg::Options::="#{dpkg_options}" ruby ruby1.8-dev libopenssl-ruby wget rsync build-essential -y && wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz && tar xfz rubygems-1.3.7.tgz && cd rubygems-1.3.7 && ruby setup.rb && cd .. && rm -rf rubygems-1.3.7* && ln -s /usr/bin/gem1.8 /usr/bin/gem && gem install chef ohai --no-ri --no-rdoc})
17
+ vm.run(%{export DEBIAN_FRONTEND=noninteractive; apt-get update && apt-get upgrade -y -o Dpkg::Options::="#{dpkg_options}" && apt-get install -o Dpkg::Options::="#{dpkg_options}" ruby ruby1.8-dev libopenssl-ruby wget rsync build-essential -y && wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz && tar xfz rubygems-1.3.7.tgz && cd rubygems-1.3.7 && ruby setup.rb && cd .. && rm -rf rubygems-1.3.7* && ln -s /usr/bin/gem1.8 /usr/bin/gem && gem install chef ohai --no-ri --no-rdoc})
15
18
  end
16
19
 
17
20
  def upload(root = "/")
@@ -26,17 +29,17 @@ module Solokit
26
29
  add_upload("#{solokit_path}/chef/*", "#{root}etc/chef") &&
27
30
  add_upload("chef/*", "#{root}etc/chef") &&
28
31
  add_upload("envs/#{@env}/chef/*", "#{root}etc/chef") &&
29
- @ssh.run("rm -rf #{root}var/chef-solo #{root}etc/chef", false) &&
30
- @ssh.rsync("#{temp_path}#{root}", root, true) &&
32
+ vm.run("rm -rf #{root}var/chef-solo #{root}etc/chef") &&
33
+ vm.upload("#{temp_path}#{root}", root) &&
31
34
  system("rm -rf #{temp_path}")
32
35
  end
33
36
 
34
37
  def run(debug = false, root = "/")
35
38
  puts "\n#{@name} (#{@env}): Running chef..."
36
39
  if debug
37
- @ssh.run("#{custom_ruby_path(root)} chef-solo -c #{root}etc/chef/solo.rb -j #{root}etc/chef/#{@name}.json -l debug", false)
40
+ vm.run("#{custom_ruby_path(root)} chef-solo -c #{root}etc/chef/solo.rb -j #{root}etc/chef/#{@name}.json -l debug")
38
41
  else
39
- @ssh.run("#{custom_ruby_path(root)} chef-solo -c #{root}etc/chef/solo.rb -j #{root}etc/chef/#{@name}.json", false)
42
+ vm.run("#{custom_ruby_path(root)} chef-solo -c #{root}etc/chef/solo.rb -j #{root}etc/chef/#{@name}.json")
40
43
  end
41
44
  end
42
45
 
@@ -49,6 +52,8 @@ module Solokit
49
52
 
50
53
  private
51
54
 
55
+ attr_reader :vm
56
+
52
57
  def temp_path
53
58
  "/tmp/solokit_upload/#{@env}-#{@name}-#{@ip}"
54
59
  end
@@ -1,3 +1,3 @@
1
1
  module Solokit
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
data/lib/ssh_login.rb ADDED
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'ssh.rb'))
2
+
3
+ module Solokit
4
+ class SshLogin
5
+ def initialize(ip, user, debug_ssh)
6
+ @ssh = SSH.new(ip, user, debug_ssh)
7
+ end
8
+
9
+ def upload(path)
10
+ @ssh.rsync("#{temp_path}#{root}", root, true)
11
+ end
12
+
13
+ def run(command)
14
+ @ssh.run(command, false)
15
+ end
16
+ end
17
+ end
data/script/test ADDED
@@ -0,0 +1 @@
1
+ rspec $@
data/solokit.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_dependency "activesupport", ">= 3.0.0"
21
21
  s.add_development_dependency "bundler"
22
+ s.add_development_dependency "rspec"
22
23
  end
@@ -0,0 +1,18 @@
1
+ require "solokit"
2
+
3
+ # This is just the beginning of a test suite. Solokit was written without tests
4
+ # when it was created long ago, but as we still use it I don't feel like adding
5
+ # more to it without tests.
6
+
7
+ describe Solokit::Chef, "#upload" do
8
+ it "note: incomplete test suite"
9
+
10
+ it "replaces any previous cookbooks on a server with the current set" do
11
+ # TODO: test the local interactions too
12
+ vm = double
13
+ expect(vm).to receive(:run).with("rm -rf /var/chef-solo /etc/chef").and_return(true)
14
+ expect(vm).to receive(:upload).with("/tmp/solokit_upload/test-name-ip/", "/").and_return(true)
15
+ chef = Solokit::Chef.new(:ip, :name, "test", false, "root", vm)
16
+ chef.upload
17
+ end
18
+ end
metadata CHANGED
@@ -1,63 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: solokit
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.16
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 15
10
- version: 0.1.15
11
6
  platform: ruby
12
- authors:
13
- - "Joakim Kolsj\xC3\xB6"
7
+ authors:
8
+ - Joakim Kolsjö
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-11-27 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2014-02-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: activesupport
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 3.0.0
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
38
31
  name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
39
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
49
54
  type: :development
50
- version_requirements: *id002
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
51
62
  description: A toolkit for provisioning (ubuntu-)servers using chef-solo.
52
- email:
63
+ email:
53
64
  - joakim.kolsjo@gmail.com
54
65
  executables: []
55
-
56
66
  extensions: []
57
-
58
67
  extra_rdoc_files: []
59
-
60
- files:
68
+ files:
61
69
  - .gitignore
62
70
  - .rvmrc
63
71
  - CHANGELOG
@@ -107,41 +115,33 @@ files:
107
115
  - lib/solokit.rb
108
116
  - lib/solokit/version.rb
109
117
  - lib/ssh.rb
118
+ - lib/ssh_login.rb
110
119
  - lib/user_json_generator.rb
120
+ - script/test
111
121
  - solokit.gemspec
112
- has_rdoc: true
113
- homepage: ""
122
+ - spec/solokit/chef_spec.rb
123
+ homepage: ''
114
124
  licenses: []
115
-
116
125
  post_install_message:
117
126
  rdoc_options: []
118
-
119
- require_paths:
127
+ require_paths:
120
128
  - lib
121
- required_ruby_version: !ruby/object:Gem::Requirement
129
+ required_ruby_version: !ruby/object:Gem::Requirement
122
130
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
136
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: 3
136
- segments:
137
- - 0
138
- version: "0"
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
139
141
  requirements: []
140
-
141
142
  rubyforge_project:
142
- rubygems_version: 1.5.3
143
+ rubygems_version: 1.8.24
143
144
  signing_key:
144
145
  specification_version: 3
145
146
  summary: A toolkit for provisioning (ubuntu-)servers using chef-solo.
146
147
  test_files: []
147
-