solid 0.1.6.beta1 → 0.1.6.beta2
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/VERSION +1 -1
- data/bin/solid +11 -1
- data/lib/solid/chef.rb +3 -3
- data/lib/solid/commands.rb +21 -47
- data/lib/solid/errors.rb +35 -0
- data/lib/solid/json.rb +13 -0
- data/lib/solid.rb +2 -0
- data/solid.gemspec +9 -3
- data/spec/fixtures/error.json +4 -0
- data/spec/fixtures/no_ssh.json +6 -0
- data/spec/fixtures/no_ssh_keys.json +6 -0
- data/spec/fixtures/no_ssh_pwd.json +6 -0
- data/spec/lib/solid/chef_spec.rb +1 -1
- data/spec/lib/solid/commands_spec.rb +33 -3
- metadata +20 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.6.
|
1
|
+
0.1.6.beta2
|
data/bin/solid
CHANGED
@@ -6,4 +6,14 @@ require 'fileutils'
|
|
6
6
|
require File.dirname(__FILE__) + '/../lib/solid'
|
7
7
|
|
8
8
|
args = ARGV.dup
|
9
|
-
|
9
|
+
if args.length > 0
|
10
|
+
Solid::Commands.new(args[0]) { run_chef }
|
11
|
+
else
|
12
|
+
puts <<-MSG
|
13
|
+
|
14
|
+
**** Welcome to Solid ******
|
15
|
+
**** Version 0.1.6.beta2 ****
|
16
|
+
**** json config file require ****
|
17
|
+
|
18
|
+
MSG
|
19
|
+
end
|
data/lib/solid/chef.rb
CHANGED
@@ -31,13 +31,13 @@ module Solid
|
|
31
31
|
result =~ /chef-solo/
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def run_solo
|
35
35
|
@logger.info "deploying..."
|
36
36
|
build_json
|
37
37
|
run_solo
|
38
38
|
end
|
39
39
|
|
40
|
-
protected
|
40
|
+
protected
|
41
41
|
|
42
42
|
def options
|
43
43
|
o = @dna['ssh-auth'] == 'key' ? { :keys => @dna["key"] } : { :password => @dna["password"] }
|
@@ -45,7 +45,7 @@ protected
|
|
45
45
|
o
|
46
46
|
end
|
47
47
|
|
48
|
-
private
|
48
|
+
private
|
49
49
|
|
50
50
|
|
51
51
|
def sudo_cmd
|
data/lib/solid/commands.rb
CHANGED
@@ -1,54 +1,28 @@
|
|
1
1
|
module Solid
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class << self
|
2
|
+
class Commands
|
3
|
+
include Solid::Errors
|
4
|
+
include Solid::Json
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# if validate_dna
|
14
|
-
# dna["servers"].each do |s|
|
15
|
-
# run(s, dna)
|
16
|
-
# end
|
17
|
-
# else
|
18
|
-
# puts <<-PRINT
|
19
|
-
# The following nodes in your json are required:
|
20
|
-
#
|
21
|
-
# * servers
|
22
|
-
# * ssh-auth
|
23
|
-
#
|
24
|
-
# if ssh-auth = key
|
25
|
-
# * key
|
26
|
-
#
|
27
|
-
# if ssh-auth = pwd
|
28
|
-
#
|
29
|
-
# * password
|
30
|
-
#
|
31
|
-
# * cookbooks
|
32
|
-
#
|
33
|
-
# PRINT
|
34
|
-
# end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def run server, with_dna
|
41
|
-
Chef.new(server, with_dna) do
|
42
|
-
install
|
43
|
-
solo
|
44
|
-
end
|
45
|
-
end
|
6
|
+
def initialize with_dna_file, &block
|
7
|
+
@dna = parse_dna(with_dna_file)
|
8
|
+
validate_dna
|
9
|
+
self.instance_eval(&block) if block_given?
|
10
|
+
end
|
46
11
|
|
47
|
-
|
48
|
-
|
49
|
-
|
12
|
+
def run_chef
|
13
|
+
@dna["servers"].each do |server|
|
14
|
+
run server
|
50
15
|
end
|
51
|
-
|
52
16
|
end
|
17
|
+
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def run server
|
22
|
+
Chef.new(server, @dna) do
|
23
|
+
install
|
24
|
+
run_solo
|
25
|
+
end
|
26
|
+
end
|
53
27
|
end
|
54
28
|
end
|
data/lib/solid/errors.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Solid
|
2
|
+
module Errors
|
3
|
+
SERVER_REQUIRED = "Servers Node Required!"
|
4
|
+
SSH_AUTH_REQUIRED = "SSH AUTH Node Required! (key or pwd)"
|
5
|
+
SSH_KEY_REQUIRED = "SSH Key node required!"
|
6
|
+
SSH_PWD_REQUIRED = "SSH Password node required!"
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def validate_dna
|
11
|
+
validate_dna_server
|
12
|
+
validate_ssh_auth
|
13
|
+
validate_ssh_key if @dna['ssh-auth'] == 'key'
|
14
|
+
validate_ssh_pwd if @dna['ssh-auth'] == 'pwd'
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate_dna_server
|
18
|
+
raise SERVER_REQUIRED unless @dna['servers']
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_ssh_auth
|
22
|
+
raise SSH_AUTH_REQUIRED unless @dna['ssh-auth'] =~ /key|pwd/
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_ssh_key
|
26
|
+
raise SSH_KEY_REQUIRED unless @dna['key']
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_ssh_pwd
|
30
|
+
raise SSH_PWD_REQUIRED unless @dna['password']
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/solid/json.rb
ADDED
data/lib/solid.rb
CHANGED
@@ -2,6 +2,8 @@ require 'net/ssh'
|
|
2
2
|
require 'crack'
|
3
3
|
require 'json/pure'
|
4
4
|
require File.dirname(__FILE__) + '/solid/constants'
|
5
|
+
require File.dirname(__FILE__) + '/solid/errors'
|
6
|
+
require File.dirname(__FILE__) + '/solid/json'
|
5
7
|
require File.dirname(__FILE__) + '/solid/ssh'
|
6
8
|
require File.dirname(__FILE__) + '/solid/chef'
|
7
9
|
require File.dirname(__FILE__) + '/solid/commands'
|
data/solid.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{solid}
|
8
|
-
s.version = "0.1.6.
|
8
|
+
s.version = "0.1.6.beta2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thing-3"]
|
@@ -31,9 +31,15 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/solid/chef.rb",
|
32
32
|
"lib/solid/commands.rb",
|
33
33
|
"lib/solid/constants.rb",
|
34
|
+
"lib/solid/errors.rb",
|
35
|
+
"lib/solid/json.rb",
|
34
36
|
"lib/solid/ssh.rb",
|
35
37
|
"solid.gemspec",
|
36
38
|
"spec/fixtures/dna.json",
|
39
|
+
"spec/fixtures/error.json",
|
40
|
+
"spec/fixtures/no_ssh.json",
|
41
|
+
"spec/fixtures/no_ssh_keys.json",
|
42
|
+
"spec/fixtures/no_ssh_pwd.json",
|
37
43
|
"spec/lib/solid/chef_spec.rb",
|
38
44
|
"spec/lib/solid/commands_spec.rb",
|
39
45
|
"spec/spec.opts",
|
@@ -42,7 +48,7 @@ Gem::Specification.new do |s|
|
|
42
48
|
s.homepage = %q{http://github.com/jackhq/solid}
|
43
49
|
s.rdoc_options = ["--charset=UTF-8"]
|
44
50
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.3.
|
51
|
+
s.rubygems_version = %q{1.3.7}
|
46
52
|
s.summary = %q{ssh deployment application}
|
47
53
|
s.test_files = [
|
48
54
|
"spec/lib/solid/chef_spec.rb",
|
@@ -54,7 +60,7 @@ Gem::Specification.new do |s|
|
|
54
60
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
61
|
s.specification_version = 3
|
56
62
|
|
57
|
-
if Gem::Version.new(Gem::
|
63
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
64
|
s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
|
59
65
|
s.add_runtime_dependency(%q<crack>, [">= 0"])
|
60
66
|
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
data/spec/lib/solid/chef_spec.rb
CHANGED
@@ -1,10 +1,40 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
describe "Solid::Command" do
|
4
|
+
before(:each) do
|
5
|
+
Solid::Chef.stub!(:new).and_return(true)
|
6
|
+
end
|
7
|
+
|
4
8
|
it "should run chef" do
|
5
|
-
Solid::Chef.stub!(:new).and_return(true)
|
6
9
|
file = File.dirname(__FILE__) + '/../../fixtures/dna.json'
|
7
|
-
Solid::Commands.run_chef
|
10
|
+
Solid::Commands.new(file) { run_chef }
|
8
11
|
end
|
12
|
+
|
13
|
+
context "should raise exception if missing" do
|
14
|
+
|
15
|
+
it "required server attribute" do
|
16
|
+
test_validate 'error', Solid::Errors::SERVER_REQUIRED
|
17
|
+
end
|
18
|
+
|
19
|
+
it "required ssh_auth attribute" do
|
20
|
+
test_validate 'no_ssh', Solid::Errors::SSH_AUTH_REQUIRED
|
21
|
+
end
|
22
|
+
|
23
|
+
it "required ssh_key attribute" do
|
24
|
+
test_validate 'no_ssh_keys', Solid::Errors::SSH_KEY_REQUIRED
|
25
|
+
end
|
26
|
+
|
27
|
+
it "required ssh_pwd attribute" do
|
28
|
+
test_validate 'no_ssh_pwd', Solid::Errors::SSH_PWD_REQUIRED
|
29
|
+
end
|
9
30
|
|
10
|
-
|
31
|
+
def test_validate(file_name, error)
|
32
|
+
file = File.dirname(__FILE__) + "/../../fixtures/#{file_name}.json"
|
33
|
+
lambda { Solid::Commands.new(file) { run_chef } }.should raise_error(error)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: -1848230054
|
4
5
|
prerelease: true
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
9
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.1.6.
|
10
|
+
- beta2
|
11
|
+
version: 0.1.6.beta2
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Thing-3
|
@@ -22,9 +23,11 @@ dependencies:
|
|
22
23
|
name: net-ssh
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
28
31
|
segments:
|
29
32
|
- 0
|
30
33
|
version: "0"
|
@@ -34,9 +37,11 @@ dependencies:
|
|
34
37
|
name: crack
|
35
38
|
prerelease: false
|
36
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
37
41
|
requirements:
|
38
42
|
- - ">="
|
39
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
40
45
|
segments:
|
41
46
|
- 0
|
42
47
|
version: "0"
|
@@ -46,9 +51,11 @@ dependencies:
|
|
46
51
|
name: json_pure
|
47
52
|
prerelease: false
|
48
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
49
55
|
requirements:
|
50
56
|
- - ">="
|
51
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
52
59
|
segments:
|
53
60
|
- 0
|
54
61
|
version: "0"
|
@@ -76,9 +83,15 @@ files:
|
|
76
83
|
- lib/solid/chef.rb
|
77
84
|
- lib/solid/commands.rb
|
78
85
|
- lib/solid/constants.rb
|
86
|
+
- lib/solid/errors.rb
|
87
|
+
- lib/solid/json.rb
|
79
88
|
- lib/solid/ssh.rb
|
80
89
|
- solid.gemspec
|
81
90
|
- spec/fixtures/dna.json
|
91
|
+
- spec/fixtures/error.json
|
92
|
+
- spec/fixtures/no_ssh.json
|
93
|
+
- spec/fixtures/no_ssh_keys.json
|
94
|
+
- spec/fixtures/no_ssh_pwd.json
|
82
95
|
- spec/lib/solid/chef_spec.rb
|
83
96
|
- spec/lib/solid/commands_spec.rb
|
84
97
|
- spec/spec.opts
|
@@ -93,16 +106,20 @@ rdoc_options:
|
|
93
106
|
require_paths:
|
94
107
|
- lib
|
95
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
96
110
|
requirements:
|
97
111
|
- - ">="
|
98
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
99
114
|
segments:
|
100
115
|
- 0
|
101
116
|
version: "0"
|
102
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
103
119
|
requirements:
|
104
120
|
- - ">"
|
105
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: 25
|
106
123
|
segments:
|
107
124
|
- 1
|
108
125
|
- 3
|
@@ -111,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
128
|
requirements: []
|
112
129
|
|
113
130
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.3.
|
131
|
+
rubygems_version: 1.3.7
|
115
132
|
signing_key:
|
116
133
|
specification_version: 3
|
117
134
|
summary: ssh deployment application
|