solid 0.1.6.rc3 → 0.1.6
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/Gemfile +5 -0
- data/README.md +89 -0
- data/VERSION +1 -1
- data/bin/solid +10 -6
- data/lib/solid.rb +4 -3
- data/lib/solid/chef.rb +42 -35
- data/lib/solid/commands.rb +21 -50
- data/lib/solid/constants.rb +30 -0
- data/lib/solid/errors.rb +35 -0
- data/lib/solid/json.rb +13 -0
- data/lib/solid/ssh.rb +9 -0
- data/solid.gemspec +24 -13
- data/spec/fixtures/dna.json +7 -0
- 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 +51 -0
- data/spec/lib/solid/commands_spec.rb +40 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +31 -18
- data/README.rdoc +0 -67
- data/lib/solid/base.rb +0 -25
- data/lib/solid/chef_solo.rb +0 -13
- data/test/helper.rb +0 -10
- data/test/test_solid.rb +0 -7
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# solid
|
2
|
+
|
3
|
+
Version: 0.1.6.beta2
|
4
|
+
|
5
|
+
master $ solid
|
6
|
+
|
7
|
+
**** Welcome to Solid ******
|
8
|
+
**** Version 0.1.6.beta2 ****
|
9
|
+
**** json config file required ****
|
10
|
+
|
11
|
+
master $
|
12
|
+
|
13
|
+
|
14
|
+
Solid is a CLI that uses ssh to remote into your servers and run chef-solo.
|
15
|
+
|
16
|
+
Solid uses Chef 9.8 and Chef-Solo to build servers remotely. Its goal is to be very easy to use. Chef-Solo is a command-line application that can execute the chef recipes once installed on the server. Chef-Solo has to be executed on the server node, but we want to execute it remotely. So "Solid" uses the Net::SSH library to connect securely and run chef-solo. It also checks to see if chef-solo is installed, and if it is not, it installs chef. Solid takes one parameter, a path to a configuration json file. This file contains all the attributes you would like to pass to chef-solo, plus some additional attributes that instruct Solid on how to connect to your server nodes, and the location of your cookbooks.
|
17
|
+
|
18
|
+
solid configuration.json
|
19
|
+
|
20
|
+
# configuration.json
|
21
|
+
|
22
|
+
{
|
23
|
+
"servers": ["server1","server2"],
|
24
|
+
"ssh-auth": "key",
|
25
|
+
"run_list": ["role[name]"],
|
26
|
+
"user": "[USER]",
|
27
|
+
"group": "[GROUP]"
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## Requirements
|
33
|
+
|
34
|
+
* Ruby
|
35
|
+
* RubyGems
|
36
|
+
* net/ssh
|
37
|
+
|
38
|
+
## Install
|
39
|
+
|
40
|
+
gem install solid
|
41
|
+
|
42
|
+
## Download Source
|
43
|
+
|
44
|
+
http://github.com/jackhq/solid
|
45
|
+
|
46
|
+
|
47
|
+
## What is a dna.json file?
|
48
|
+
|
49
|
+
It is a file that contains instructions for chef on how to setup and configure your servers, and applications. To learn more go to http://opscode.com
|
50
|
+
|
51
|
+
{
|
52
|
+
"servers": ["server1","server2"],
|
53
|
+
"ssh-auth": "key",
|
54
|
+
"run_list": ["role[name]"],
|
55
|
+
"user": "[USER]",
|
56
|
+
"group": "[GROUP]"
|
57
|
+
}
|
58
|
+
|
59
|
+
## How to use
|
60
|
+
|
61
|
+
* Create your dna.json file
|
62
|
+
|
63
|
+
* Make sure it has the following root attributes:
|
64
|
+
|
65
|
+
* servers - array of servers
|
66
|
+
* ssh-auth - (key|pwd) - type ssh authentication
|
67
|
+
* key - if ssh authentication is key based
|
68
|
+
* password - if ssh authentication is pwd based
|
69
|
+
* port
|
70
|
+
|
71
|
+
* Execute
|
72
|
+
|
73
|
+
solid dna.json
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
## Note on Patches/Pull Requests
|
78
|
+
|
79
|
+
* Fork the project.
|
80
|
+
* Make your feature addition or bug fix.
|
81
|
+
* Add tests for it. This is important so I don't break it in a
|
82
|
+
future version unintentionally.
|
83
|
+
* Commit, do not mess with rakefile, version, or history.
|
84
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
85
|
+
* Send me a pull request. Bonus points for topic branches.
|
86
|
+
|
87
|
+
== Copyright
|
88
|
+
|
89
|
+
Copyright (c) 2010 Thing-3. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.6
|
1
|
+
0.1.6
|
data/bin/solid
CHANGED
@@ -6,10 +6,14 @@ require 'fileutils'
|
|
6
6
|
require File.dirname(__FILE__) + '/../lib/solid'
|
7
7
|
|
8
8
|
args = ARGV.dup
|
9
|
-
|
10
|
-
|
11
|
-
if args.first == 'logs'
|
12
|
-
Solid::Commands.logs
|
9
|
+
if args.length > 0
|
10
|
+
Solid::Commands.new(args[0]) { run_chef }
|
13
11
|
else
|
14
|
-
|
15
|
-
|
12
|
+
puts <<-MSG
|
13
|
+
|
14
|
+
**** Welcome to Solid ******
|
15
|
+
**** Version 0.1.6.beta2 ****
|
16
|
+
**** json config file required ****
|
17
|
+
|
18
|
+
MSG
|
19
|
+
end
|
data/lib/solid.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'net/ssh'
|
2
2
|
require 'crack'
|
3
3
|
require 'json/pure'
|
4
|
-
|
5
|
-
require File.dirname(__FILE__) + '/solid/
|
6
|
-
require File.dirname(__FILE__) + '/solid/
|
4
|
+
require File.dirname(__FILE__) + '/solid/constants'
|
5
|
+
require File.dirname(__FILE__) + '/solid/errors'
|
6
|
+
require File.dirname(__FILE__) + '/solid/json'
|
7
|
+
require File.dirname(__FILE__) + '/solid/ssh'
|
7
8
|
require File.dirname(__FILE__) + '/solid/chef'
|
8
9
|
require File.dirname(__FILE__) + '/solid/commands'
|
data/lib/solid/chef.rb
CHANGED
@@ -1,81 +1,88 @@
|
|
1
1
|
module Solid
|
2
2
|
|
3
|
-
class Chef
|
4
|
-
|
5
|
-
|
6
|
-
RUBYGEMS_FILE = "#{RUBYGEMS_DIR}.tgz"
|
7
|
-
RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/70696/#{RUBYGEMS_FILE}"
|
3
|
+
class Chef
|
4
|
+
include Solid::Constants
|
5
|
+
include Solid::SSH
|
8
6
|
|
9
|
-
def initialize(server,
|
7
|
+
def initialize(server, dna, logger=Logger.new(STDOUT), &block)
|
10
8
|
@server = server
|
11
|
-
@
|
12
|
-
@
|
9
|
+
@dna = dna
|
10
|
+
@logger = logger
|
11
|
+
@level = "info"
|
12
|
+
@user = @dna["user"]
|
13
|
+
@cookbooks = @dna["cookbooks"]
|
14
|
+
self.instance_eval(&block) if block_given?
|
13
15
|
end
|
14
16
|
|
15
17
|
def install
|
16
18
|
unless installed?
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
build_solo_rb ssh
|
22
|
-
end
|
19
|
+
@logger.info "installing..."
|
20
|
+
install_chef_prereqs
|
21
|
+
install_chef_gems
|
22
|
+
build_solo_rb
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def installed?
|
27
27
|
result = false
|
28
|
-
|
29
|
-
|
28
|
+
@logger.info "checking if installed"
|
29
|
+
Net::SSH.start(@server, @user, self.options) do |ssh|
|
30
30
|
result = ssh.exec!("which chef-solo")
|
31
31
|
end
|
32
32
|
result =~ /chef-solo/
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
build_json dna, ssh
|
40
|
-
run_solo cookbooks, ssh
|
41
|
-
end
|
35
|
+
def run_solo
|
36
|
+
@logger.info "deploying..."
|
37
|
+
build_json
|
38
|
+
run_chef_solo
|
42
39
|
end
|
43
40
|
|
44
|
-
|
41
|
+
protected
|
42
|
+
|
43
|
+
def options
|
44
|
+
o = @dna['ssh-auth'] == 'key' ? { :keys => @dna["key"] } : { :password => @dna["password"] }
|
45
|
+
o.merge!(:port => @dna['port']) if @dna['port']
|
46
|
+
o
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
45
51
|
|
46
52
|
def sudo_cmd
|
47
53
|
'sudo '
|
48
54
|
end
|
55
|
+
|
49
56
|
|
50
|
-
def install_chef_prereqs
|
57
|
+
def install_chef_prereqs
|
51
58
|
[ sudo_cmd + "apt-get update -y",
|
52
59
|
sudo_cmd + "apt-get install #{APT_GET.join(' ')} -y",
|
53
60
|
"wget #{RUBYGEMS_URL} && tar zxf #{RUBYGEMS_FILE} && cd #{RUBYGEMS_DIR} && sudo ruby setup.rb && sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem",
|
54
61
|
sudo_cmd + "gem update --system"].each do |line|
|
55
|
-
|
62
|
+
ssh_exec line
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
59
|
-
def install_chef_gems
|
66
|
+
def install_chef_gems
|
60
67
|
CHEF_GEMS.each do |gem|
|
61
|
-
|
68
|
+
ssh_exec "#{sudo_cmd} gem install #{gem[:name]} -v #{gem[:version]}"
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
65
|
-
def build_solo_rb
|
72
|
+
def build_solo_rb
|
66
73
|
['file_cache_path "/tmp/chef-solo"',
|
67
74
|
'cookbook_path ["/tmp/chef-solo/cookbooks", "/tmp/chef-solo/site-cookbooks"]'].each do |line|
|
68
|
-
|
75
|
+
ssh_exec "echo '#{line}' >> solo.rb"
|
69
76
|
end
|
70
77
|
end
|
71
78
|
|
72
|
-
def build_json
|
73
|
-
|
79
|
+
def build_json
|
80
|
+
ssh_exec "echo \"#{@dna.to_json.gsub('"','\"')}\" > dna.json"
|
74
81
|
end
|
75
82
|
|
76
|
-
def
|
77
|
-
|
83
|
+
def run_chef_solo
|
84
|
+
ssh_exec sudo_cmd + " chef-solo -c ~/solo.rb -l #{@level} -j dna.json -r #{@cookbooks}"
|
78
85
|
end
|
79
|
-
|
86
|
+
|
80
87
|
end
|
81
88
|
end
|
data/lib/solid/commands.rb
CHANGED
@@ -1,57 +1,28 @@
|
|
1
1
|
module Solid
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class << self
|
6
|
-
|
7
|
-
def init(dna_file)
|
8
|
-
chef_solo = ChefSolo.new
|
9
|
-
chef_solo.install
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
def deploy(dna_file)
|
14
|
-
dna = Crack::JSON.parse(get_dna(dna_file))
|
15
|
-
dna["servers"].each do |s|
|
16
|
-
run(s, dna)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def rollback(dna_file)
|
21
|
-
dna = Crack::JSON.parse(get_dna(dna_file))
|
22
|
-
dna.merge!(:action => 'rollback')
|
23
|
-
dna["servers"].each do |s|
|
24
|
-
run(s, dna)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
2
|
+
class Commands
|
3
|
+
include Solid::Errors
|
4
|
+
include Solid::Json
|
28
5
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def run(s, dna)
|
39
|
-
options = dna['ssh-auth'] == 'key' ? { :keys => dna["key"] } : { :password => dna["password"] }
|
40
|
-
options.merge!(:port => dna['port']) if dna['port']
|
41
|
-
chef = Chef.new(s, dna["user"], options)
|
42
|
-
chef.install
|
43
|
-
chef.solo dna, dna["cookbooks"]
|
44
|
-
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
|
45
11
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
File.open(dna_file, 'r') do |f|
|
50
|
-
dna = f.read
|
51
|
-
end
|
52
|
-
dna
|
12
|
+
def run_chef
|
13
|
+
@dna["servers"].each do |server|
|
14
|
+
run server
|
53
15
|
end
|
54
|
-
|
55
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
|
56
27
|
end
|
57
28
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Solid
|
2
|
+
module Constants
|
3
|
+
APT_GET = %w{ ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential git-core xfsprogs }
|
4
|
+
RUBYGEMS_DIR = 'rubygems-1.3.7'
|
5
|
+
RUBYGEMS_FILE = "#{RUBYGEMS_DIR}.tgz"
|
6
|
+
RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/70696/#{RUBYGEMS_FILE}"
|
7
|
+
|
8
|
+
CHEF_GEMS = [
|
9
|
+
{:name => 'uuidtools', :version => '2.1.1'},
|
10
|
+
{:name => 'highline', :version => '1.6.1'},
|
11
|
+
{:name => 'moneta', :version => '0.6.0'},
|
12
|
+
{:name => 'extlib', :version => '0.9.15'},
|
13
|
+
{:name => 'abstract', :version => '1.0.0'},
|
14
|
+
{:name => 'erubis', :version => '2.6.6'},
|
15
|
+
{:name => 'json', :version => '1.4.2'},
|
16
|
+
{:name => 'bunny', :version => '0.6.0'},
|
17
|
+
{:name => 'mime-types', :version => '1.16'},
|
18
|
+
{:name => 'rest-client', :version => '1.5.1'},
|
19
|
+
{:name => 'systemu', :version => '1.2.0'},
|
20
|
+
{:name => 'mixlib-cli', :version => '1.2.0'},
|
21
|
+
{:name => 'mixlib-config', :version => '1.1.2'},
|
22
|
+
{:name => 'mixlib-log', :version => '1.1.0'},
|
23
|
+
{:name => 'mixlib-authentication', :version => '1.1.4'},
|
24
|
+
{:name => 'ohai', :version => '0.5.6'},
|
25
|
+
{:name => 'chef', :version => '0.9.8'}
|
26
|
+
]
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
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/ssh.rb
ADDED
data/solid.gemspec
CHANGED
@@ -5,51 +5,62 @@
|
|
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"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thing-3"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-18}
|
13
13
|
s.default_executable = %q{solid}
|
14
14
|
s.description = %q{ssh deployment application}
|
15
15
|
s.email = %q{thing3@jackhq.com}
|
16
16
|
s.executables = ["solid"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
"README.
|
19
|
+
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
|
+
"Gemfile",
|
24
25
|
"LICENSE",
|
25
|
-
"README.
|
26
|
+
"README.md",
|
26
27
|
"Rakefile",
|
27
28
|
"VERSION",
|
28
29
|
"bin/solid",
|
29
30
|
"lib/solid.rb",
|
30
|
-
"lib/solid/base.rb",
|
31
31
|
"lib/solid/chef.rb",
|
32
|
-
"lib/solid/chef_solo.rb",
|
33
32
|
"lib/solid/commands.rb",
|
33
|
+
"lib/solid/constants.rb",
|
34
|
+
"lib/solid/errors.rb",
|
35
|
+
"lib/solid/json.rb",
|
36
|
+
"lib/solid/ssh.rb",
|
34
37
|
"solid.gemspec",
|
35
|
-
"
|
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",
|
43
|
+
"spec/lib/solid/chef_spec.rb",
|
44
|
+
"spec/lib/solid/commands_spec.rb",
|
45
|
+
"spec/spec.opts",
|
46
|
+
"spec/spec_helper.rb"
|
37
47
|
]
|
38
48
|
s.homepage = %q{http://github.com/jackhq/solid}
|
39
49
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
50
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.3.
|
51
|
+
s.rubygems_version = %q{1.3.7}
|
42
52
|
s.summary = %q{ssh deployment application}
|
43
53
|
s.test_files = [
|
44
|
-
"
|
45
|
-
"
|
54
|
+
"spec/lib/solid/chef_spec.rb",
|
55
|
+
"spec/lib/solid/commands_spec.rb",
|
56
|
+
"spec/spec_helper.rb"
|
46
57
|
]
|
47
58
|
|
48
59
|
if s.respond_to? :specification_version then
|
49
60
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
61
|
s.specification_version = 3
|
51
62
|
|
52
|
-
if Gem::Version.new(Gem::
|
63
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
64
|
s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
|
54
65
|
s.add_runtime_dependency(%q<crack>, [">= 0"])
|
55
66
|
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "Solid::Chef" do
|
4
|
+
before(:each) do
|
5
|
+
@server = 'ec2-184-73-32-12.compute-1.amazonaws.com'
|
6
|
+
@with_dna = Crack::JSON.parse(<<-JSON
|
7
|
+
{
|
8
|
+
'servers': [ 'ec2-184-73-32-12.compute-1.amazonaws.com'],
|
9
|
+
'ssh-auth': 'key',
|
10
|
+
'user': 'ubuntu',
|
11
|
+
'group': 'ubuntu',
|
12
|
+
'key': "~/.ec2/ec2-dev"
|
13
|
+
}
|
14
|
+
JSON
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should check if chef is installed" do
|
19
|
+
ssh = mock("Net::SSH")
|
20
|
+
ssh.stub!(:exec!).and_return("chef-solo")
|
21
|
+
Net::SSH.stub!(:start).and_return(ssh)
|
22
|
+
|
23
|
+
Solid::Chef.new(@server, @with_dna) do
|
24
|
+
print installed?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should install chef on node" do
|
29
|
+
ssh = mock("Net::SSH")
|
30
|
+
ssh.stub!(:exec!).and_return("chef-solo")
|
31
|
+
Net::SSH.stub!(:start).and_return(ssh)
|
32
|
+
|
33
|
+
Solid::Chef.new(@server, @with_dna) do
|
34
|
+
print install
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should chef solo on node" do
|
40
|
+
ssh = mock("Net::SSH")
|
41
|
+
ssh.stub!(:exec!).and_return("chef-solo")
|
42
|
+
Net::SSH.stub!(:start).and_return(ssh)
|
43
|
+
|
44
|
+
Solid::Chef.new(@server, @with_dna) do
|
45
|
+
print run_solo
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "Solid::Command" do
|
4
|
+
before(:each) do
|
5
|
+
Solid::Chef.stub!(:new).and_return(true)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should run chef" do
|
9
|
+
file = File.dirname(__FILE__) + '/../../fixtures/dna.json'
|
10
|
+
Solid::Commands.new(file) { run_chef }
|
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
|
30
|
+
|
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
|
+
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
|
10
|
-
version: 0.1.6.rc3
|
9
|
+
version: 0.1.6
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Thing-3
|
@@ -15,13 +14,14 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-18 00:00:00 -04:00
|
19
18
|
default_executable: solid
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: net-ssh
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
@@ -34,6 +34,7 @@ dependencies:
|
|
34
34
|
name: crack
|
35
35
|
prerelease: false
|
36
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
37
38
|
requirements:
|
38
39
|
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
@@ -46,6 +47,7 @@ dependencies:
|
|
46
47
|
name: json_pure
|
47
48
|
prerelease: false
|
48
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
49
51
|
requirements:
|
50
52
|
- - ">="
|
51
53
|
- !ruby/object:Gem::Version
|
@@ -62,23 +64,33 @@ extensions: []
|
|
62
64
|
|
63
65
|
extra_rdoc_files:
|
64
66
|
- LICENSE
|
65
|
-
- README.
|
67
|
+
- README.md
|
66
68
|
files:
|
67
69
|
- .document
|
68
70
|
- .gitignore
|
71
|
+
- Gemfile
|
69
72
|
- LICENSE
|
70
|
-
- README.
|
73
|
+
- README.md
|
71
74
|
- Rakefile
|
72
75
|
- VERSION
|
73
76
|
- bin/solid
|
74
77
|
- lib/solid.rb
|
75
|
-
- lib/solid/base.rb
|
76
78
|
- lib/solid/chef.rb
|
77
|
-
- lib/solid/chef_solo.rb
|
78
79
|
- lib/solid/commands.rb
|
80
|
+
- lib/solid/constants.rb
|
81
|
+
- lib/solid/errors.rb
|
82
|
+
- lib/solid/json.rb
|
83
|
+
- lib/solid/ssh.rb
|
79
84
|
- solid.gemspec
|
80
|
-
-
|
81
|
-
-
|
85
|
+
- spec/fixtures/dna.json
|
86
|
+
- spec/fixtures/error.json
|
87
|
+
- spec/fixtures/no_ssh.json
|
88
|
+
- spec/fixtures/no_ssh_keys.json
|
89
|
+
- spec/fixtures/no_ssh_pwd.json
|
90
|
+
- spec/lib/solid/chef_spec.rb
|
91
|
+
- spec/lib/solid/commands_spec.rb
|
92
|
+
- spec/spec.opts
|
93
|
+
- spec/spec_helper.rb
|
82
94
|
has_rdoc: true
|
83
95
|
homepage: http://github.com/jackhq/solid
|
84
96
|
licenses: []
|
@@ -89,6 +101,7 @@ rdoc_options:
|
|
89
101
|
require_paths:
|
90
102
|
- lib
|
91
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
92
105
|
requirements:
|
93
106
|
- - ">="
|
94
107
|
- !ruby/object:Gem::Version
|
@@ -96,21 +109,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
109
|
- 0
|
97
110
|
version: "0"
|
98
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
99
113
|
requirements:
|
100
|
-
- - "
|
114
|
+
- - ">="
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
segments:
|
103
|
-
-
|
104
|
-
|
105
|
-
- 1
|
106
|
-
version: 1.3.1
|
117
|
+
- 0
|
118
|
+
version: "0"
|
107
119
|
requirements: []
|
108
120
|
|
109
121
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.3.
|
122
|
+
rubygems_version: 1.3.7
|
111
123
|
signing_key:
|
112
124
|
specification_version: 3
|
113
125
|
summary: ssh deployment application
|
114
126
|
test_files:
|
115
|
-
-
|
116
|
-
-
|
127
|
+
- spec/lib/solid/chef_spec.rb
|
128
|
+
- spec/lib/solid/commands_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
data/README.rdoc
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
= solid
|
2
|
-
|
3
|
-
An awesome way to deploy with chef!
|
4
|
-
|
5
|
-
== Requirements
|
6
|
-
|
7
|
-
* Ruby
|
8
|
-
* RubyGems
|
9
|
-
* net/ssh
|
10
|
-
|
11
|
-
== Install
|
12
|
-
|
13
|
-
gem install solid
|
14
|
-
|
15
|
-
== Download Source
|
16
|
-
|
17
|
-
http://github.com/jackhq/solid
|
18
|
-
|
19
|
-
|
20
|
-
== What is it?
|
21
|
-
|
22
|
-
Solid is a command line interface that takes a dna.json file as an argument. It uses this file to establish a ssh connection for each of the application servers specified in the document either by user/key or user/password connections. Then it simply looks for chef-solo, if not available, it installs chef, if available it runs chef-solo, with the dna.json file.
|
23
|
-
|
24
|
-
== What is a dna.json file?
|
25
|
-
|
26
|
-
It is a file that contains instructions for chef on how to setup and configure your servers, and applications. To learn more go to http://opscode.com
|
27
|
-
|
28
|
-
== How to use
|
29
|
-
|
30
|
-
* Create your dna.json file
|
31
|
-
|
32
|
-
* Make sure it has the following root attributes:
|
33
|
-
|
34
|
-
* servers - array of servers
|
35
|
-
* ssh-auth - (key|pwd) - type ssh authentication
|
36
|
-
* key - if ssh authentication is key based
|
37
|
-
* password - if ssh authentication is pwd based
|
38
|
-
* port
|
39
|
-
|
40
|
-
* Execute
|
41
|
-
|
42
|
-
solid deploy dna.json
|
43
|
-
|
44
|
-
* Rollback
|
45
|
-
|
46
|
-
solid rollback dna.json
|
47
|
-
|
48
|
-
* Logs
|
49
|
-
|
50
|
-
solid logs
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
== Note on Patches/Pull Requests
|
56
|
-
|
57
|
-
* Fork the project.
|
58
|
-
* Make your feature addition or bug fix.
|
59
|
-
* Add tests for it. This is important so I don't break it in a
|
60
|
-
future version unintentionally.
|
61
|
-
* Commit, do not mess with rakefile, version, or history.
|
62
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
63
|
-
* Send me a pull request. Bonus points for topic branches.
|
64
|
-
|
65
|
-
== Copyright
|
66
|
-
|
67
|
-
Copyright (c) 2010 Thing-3. See LICENSE for details.
|
data/lib/solid/base.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Solid
|
2
|
-
|
3
|
-
class Base
|
4
|
-
CHEF_GEMS = [
|
5
|
-
{:name => 'uuidtools', :version => '2.1.1'},
|
6
|
-
{:name => 'highline', :version => '1.6.1'},
|
7
|
-
{:name => 'moneta', :version => '0.6.0'},
|
8
|
-
{:name => 'extlib', :version => '0.9.15'},
|
9
|
-
{:name => 'erubis', :version => '2.6.6'},
|
10
|
-
{:name => 'json', :version => '1.4.2'},
|
11
|
-
{:name => 'bunny', :version => '0.6.0'},
|
12
|
-
{:name => 'rest-client', :version => '1.5.1'},
|
13
|
-
{:name => 'systemu', :version => '1.2.0'},
|
14
|
-
{:name => 'mixlib-authentication', :version => '1.1.4'},
|
15
|
-
{:name => 'mixlib-log', :version => '1.1.0'},
|
16
|
-
{:name => 'mixlib-cli', :version => '1.2.0'},
|
17
|
-
{:name => 'mixlib-config', :version => '1.1.2'},
|
18
|
-
{:name => 'ohai', :version => '0.5.6'},
|
19
|
-
{:name => 'chef', :version => '0.9.8'}
|
20
|
-
]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
data/lib/solid/chef_solo.rb
DELETED
data/test/helper.rb
DELETED