solid 0.1.6.beta2 → 0.1.6.rc1
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/README.rdoc +67 -0
- data/VERSION +1 -1
- data/bin/solid +6 -10
- data/lib/solid/base.rb +25 -0
- data/lib/solid/chef.rb +35 -41
- data/lib/solid/chef_solo.rb +13 -0
- data/lib/solid/commands.rb +50 -21
- data/lib/solid.rb +3 -4
- data/solid.gemspec +12 -23
- data/test/helper.rb +10 -0
- data/test/test_solid.rb +7 -0
- metadata +12 -34
- data/Gemfile +0 -5
- data/README.md +0 -80
- data/lib/solid/constants.rb +0 -30
- data/lib/solid/errors.rb +0 -35
- data/lib/solid/json.rb +0 -13
- data/lib/solid/ssh.rb +0 -9
- data/spec/fixtures/dna.json +0 -7
- data/spec/fixtures/error.json +0 -4
- data/spec/fixtures/no_ssh.json +0 -6
- data/spec/fixtures/no_ssh_keys.json +0 -6
- data/spec/fixtures/no_ssh_pwd.json +0 -6
- data/spec/lib/solid/chef_spec.rb +0 -51
- data/spec/lib/solid/commands_spec.rb +0 -40
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -2
data/README.rdoc
ADDED
@@ -0,0 +1,67 @@
|
|
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.6.
|
1
|
+
0.1.6.rc1
|
data/bin/solid
CHANGED
@@ -6,14 +6,10 @@ require 'fileutils'
|
|
6
6
|
require File.dirname(__FILE__) + '/../lib/solid'
|
7
7
|
|
8
8
|
args = ARGV.dup
|
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
9
|
|
18
|
-
|
19
|
-
|
10
|
+
#puts args.first
|
11
|
+
if args.first == 'logs'
|
12
|
+
Solid::Commands.logs
|
13
|
+
else
|
14
|
+
Solid::Commands.send(args.first, args[1])
|
15
|
+
end
|
data/lib/solid/base.rb
ADDED
@@ -0,0 +1,25 @@
|
|
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.rb
CHANGED
@@ -1,87 +1,81 @@
|
|
1
1
|
module Solid
|
2
2
|
|
3
|
-
class Chef
|
4
|
-
|
5
|
-
|
3
|
+
class Chef < Solid::Base
|
4
|
+
APT_GET = %w{ ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential git-core xfsprogs }
|
5
|
+
RUBYGEMS_DIR = 'rubygems-1.3.7'
|
6
|
+
RUBYGEMS_FILE = "#{RUBYGEMS_DIR}.tgz"
|
7
|
+
RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/70696/#{RUBYGEMS_FILE}"
|
6
8
|
|
7
|
-
def initialize(server,
|
9
|
+
def initialize(server, user, options = {})
|
8
10
|
@server = server
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@user = @dna["user"]
|
12
|
-
@cookbooks = @dna["cookbooks"]
|
13
|
-
self.instance_eval(&block) if block_given?
|
11
|
+
@user = user
|
12
|
+
@options = options
|
14
13
|
end
|
15
14
|
|
16
15
|
def install
|
17
16
|
unless installed?
|
18
|
-
@
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
Net::SSH.start(@server, @user, @options) do |ssh|
|
18
|
+
puts "installing..."
|
19
|
+
install_chef_prereqs ssh
|
20
|
+
install_chef_gems ssh
|
21
|
+
build_solo_rb ssh
|
22
|
+
end
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
def installed?
|
26
27
|
result = false
|
27
|
-
@
|
28
|
-
|
28
|
+
Net::SSH.start(@server, @user, @options) do |ssh|
|
29
|
+
puts "checking if installed"
|
29
30
|
result = ssh.exec!("which chef-solo")
|
30
31
|
end
|
31
32
|
result =~ /chef-solo/
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
@
|
36
|
-
|
37
|
-
|
35
|
+
def solo(dna, cookbooks, sudo=true)
|
36
|
+
puts @options.inspect
|
37
|
+
Net::SSH.start(@server, @user, @options) do |ssh|
|
38
|
+
puts "deploying..."
|
39
|
+
build_json dna, ssh
|
40
|
+
run_solo cookbooks, ssh
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
def options
|
43
|
-
o = @dna['ssh-auth'] == 'key' ? { :keys => @dna["key"] } : { :password => @dna["password"] }
|
44
|
-
o.merge!(:port => @dna['port']) if @dna['port']
|
45
|
-
o
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
44
|
+
private
|
50
45
|
|
51
46
|
def sudo_cmd
|
52
47
|
'sudo '
|
53
48
|
end
|
54
|
-
|
55
49
|
|
56
|
-
def install_chef_prereqs
|
50
|
+
def install_chef_prereqs ssh
|
57
51
|
[ sudo_cmd + "apt-get update -y",
|
58
52
|
sudo_cmd + "apt-get install #{APT_GET.join(' ')} -y",
|
59
53
|
"wget #{RUBYGEMS_URL} && tar zxf #{RUBYGEMS_FILE} && cd #{RUBYGEMS_DIR} && sudo ruby setup.rb && sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem",
|
60
54
|
sudo_cmd + "gem update --system"].each do |line|
|
61
|
-
|
55
|
+
ssh.exec! line
|
62
56
|
end
|
63
57
|
end
|
64
58
|
|
65
|
-
def install_chef_gems
|
59
|
+
def install_chef_gems ssh
|
66
60
|
CHEF_GEMS.each do |gem|
|
67
|
-
|
61
|
+
puts ssh.exec! sudo_cmd + %Q{ gem install #{gem[:name]} -v #{gem[:version]} --no-ri --no-rdoc }
|
68
62
|
end
|
69
63
|
end
|
70
64
|
|
71
|
-
def build_solo_rb
|
65
|
+
def build_solo_rb ssh
|
72
66
|
['file_cache_path "/tmp/chef-solo"',
|
73
67
|
'cookbook_path ["/tmp/chef-solo/cookbooks", "/tmp/chef-solo/site-cookbooks"]'].each do |line|
|
74
|
-
|
68
|
+
ssh.exec! "echo '#{line}' >> solo.rb"
|
75
69
|
end
|
76
70
|
end
|
77
71
|
|
78
|
-
def build_json
|
79
|
-
|
72
|
+
def build_json dna, ssh
|
73
|
+
ssh.exec!("echo \"#{dna.to_json.gsub('"','\"')}\" > dna.json")
|
80
74
|
end
|
81
75
|
|
82
|
-
def run_solo
|
83
|
-
|
76
|
+
def run_solo cookbooks, ssh
|
77
|
+
puts ssh.exec!(sudo_cmd + " chef-solo -c ~/solo.rb -l debug -j dna.json -r #{cookbooks}")
|
84
78
|
end
|
85
|
-
|
79
|
+
|
86
80
|
end
|
87
81
|
end
|
data/lib/solid/commands.rb
CHANGED
@@ -1,28 +1,57 @@
|
|
1
1
|
module Solid
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
module Commands
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def init
|
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
|
28
|
+
|
29
|
+
def logs
|
30
|
+
puts "Comming Soon!"
|
31
|
+
end
|
32
|
+
|
5
33
|
|
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
|
11
34
|
|
12
|
-
|
13
|
-
|
14
|
-
|
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"]
|
15
44
|
end
|
45
|
+
|
46
|
+
|
47
|
+
def get_dna(dna_file)
|
48
|
+
dna = ""
|
49
|
+
File.open(dna_file, 'r') do |f|
|
50
|
+
dna = f.read
|
51
|
+
end
|
52
|
+
dna
|
53
|
+
end
|
54
|
+
|
16
55
|
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
|
27
56
|
end
|
28
57
|
end
|
data/lib/solid.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
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/
|
7
|
-
require File.dirname(__FILE__) + '/solid/ssh'
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/solid/base'
|
6
|
+
require File.dirname(__FILE__) + '/solid/chef_solo'
|
8
7
|
require File.dirname(__FILE__) + '/solid/chef'
|
9
8
|
require File.dirname(__FILE__) + '/solid/commands'
|
data/solid.gemspec
CHANGED
@@ -5,62 +5,51 @@
|
|
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.rc1"
|
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"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-10}
|
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.rdoc"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
|
-
"Gemfile",
|
25
24
|
"LICENSE",
|
26
|
-
"README.
|
25
|
+
"README.rdoc",
|
27
26
|
"Rakefile",
|
28
27
|
"VERSION",
|
29
28
|
"bin/solid",
|
30
29
|
"lib/solid.rb",
|
30
|
+
"lib/solid/base.rb",
|
31
31
|
"lib/solid/chef.rb",
|
32
|
+
"lib/solid/chef_solo.rb",
|
32
33
|
"lib/solid/commands.rb",
|
33
|
-
"lib/solid/constants.rb",
|
34
|
-
"lib/solid/errors.rb",
|
35
|
-
"lib/solid/json.rb",
|
36
|
-
"lib/solid/ssh.rb",
|
37
34
|
"solid.gemspec",
|
38
|
-
"
|
39
|
-
"
|
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"
|
35
|
+
"test/helper.rb",
|
36
|
+
"test/test_solid.rb"
|
47
37
|
]
|
48
38
|
s.homepage = %q{http://github.com/jackhq/solid}
|
49
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
50
40
|
s.require_paths = ["lib"]
|
51
|
-
s.rubygems_version = %q{1.3.
|
41
|
+
s.rubygems_version = %q{1.3.6}
|
52
42
|
s.summary = %q{ssh deployment application}
|
53
43
|
s.test_files = [
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"spec/spec_helper.rb"
|
44
|
+
"test/helper.rb",
|
45
|
+
"test/test_solid.rb"
|
57
46
|
]
|
58
47
|
|
59
48
|
if s.respond_to? :specification_version then
|
60
49
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
50
|
s.specification_version = 3
|
62
51
|
|
63
|
-
if Gem::Version.new(Gem::
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
53
|
s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
|
65
54
|
s.add_runtime_dependency(%q<crack>, [">= 0"])
|
66
55
|
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
data/test/helper.rb
ADDED
data/test/test_solid.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -1848230054
|
5
4
|
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
8
|
- 6
|
10
|
-
-
|
11
|
-
version: 0.1.6.
|
9
|
+
- rc1
|
10
|
+
version: 0.1.6.rc1
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Thing-3
|
@@ -16,18 +15,16 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-10 00:00:00 -04:00
|
20
19
|
default_executable: solid
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: net-ssh
|
24
23
|
prerelease: false
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
25
|
requirements:
|
28
26
|
- - ">="
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
28
|
segments:
|
32
29
|
- 0
|
33
30
|
version: "0"
|
@@ -37,11 +34,9 @@ dependencies:
|
|
37
34
|
name: crack
|
38
35
|
prerelease: false
|
39
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
37
|
requirements:
|
42
38
|
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
40
|
segments:
|
46
41
|
- 0
|
47
42
|
version: "0"
|
@@ -51,11 +46,9 @@ dependencies:
|
|
51
46
|
name: json_pure
|
52
47
|
prerelease: false
|
53
48
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
49
|
requirements:
|
56
50
|
- - ">="
|
57
51
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
52
|
segments:
|
60
53
|
- 0
|
61
54
|
version: "0"
|
@@ -69,33 +62,23 @@ extensions: []
|
|
69
62
|
|
70
63
|
extra_rdoc_files:
|
71
64
|
- LICENSE
|
72
|
-
- README.
|
65
|
+
- README.rdoc
|
73
66
|
files:
|
74
67
|
- .document
|
75
68
|
- .gitignore
|
76
|
-
- Gemfile
|
77
69
|
- LICENSE
|
78
|
-
- README.
|
70
|
+
- README.rdoc
|
79
71
|
- Rakefile
|
80
72
|
- VERSION
|
81
73
|
- bin/solid
|
82
74
|
- lib/solid.rb
|
75
|
+
- lib/solid/base.rb
|
83
76
|
- lib/solid/chef.rb
|
77
|
+
- lib/solid/chef_solo.rb
|
84
78
|
- lib/solid/commands.rb
|
85
|
-
- lib/solid/constants.rb
|
86
|
-
- lib/solid/errors.rb
|
87
|
-
- lib/solid/json.rb
|
88
|
-
- lib/solid/ssh.rb
|
89
79
|
- solid.gemspec
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- spec/fixtures/no_ssh.json
|
93
|
-
- spec/fixtures/no_ssh_keys.json
|
94
|
-
- spec/fixtures/no_ssh_pwd.json
|
95
|
-
- spec/lib/solid/chef_spec.rb
|
96
|
-
- spec/lib/solid/commands_spec.rb
|
97
|
-
- spec/spec.opts
|
98
|
-
- spec/spec_helper.rb
|
80
|
+
- test/helper.rb
|
81
|
+
- test/test_solid.rb
|
99
82
|
has_rdoc: true
|
100
83
|
homepage: http://github.com/jackhq/solid
|
101
84
|
licenses: []
|
@@ -106,20 +89,16 @@ rdoc_options:
|
|
106
89
|
require_paths:
|
107
90
|
- lib
|
108
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
92
|
requirements:
|
111
93
|
- - ">="
|
112
94
|
- !ruby/object:Gem::Version
|
113
|
-
hash: 3
|
114
95
|
segments:
|
115
96
|
- 0
|
116
97
|
version: "0"
|
117
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
99
|
requirements:
|
120
100
|
- - ">"
|
121
101
|
- !ruby/object:Gem::Version
|
122
|
-
hash: 25
|
123
102
|
segments:
|
124
103
|
- 1
|
125
104
|
- 3
|
@@ -128,11 +107,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
107
|
requirements: []
|
129
108
|
|
130
109
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.3.
|
110
|
+
rubygems_version: 1.3.6
|
132
111
|
signing_key:
|
133
112
|
specification_version: 3
|
134
113
|
summary: ssh deployment application
|
135
114
|
test_files:
|
136
|
-
-
|
137
|
-
-
|
138
|
-
- spec/spec_helper.rb
|
115
|
+
- test/helper.rb
|
116
|
+
- test/test_solid.rb
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# solid
|
2
|
-
|
3
|
-
Version: 0.1.6.beta1
|
4
|
-
|
5
|
-
Solid is a CLI that uses ssh to remote into your servers and run chef-solo.
|
6
|
-
|
7
|
-
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.
|
8
|
-
|
9
|
-
solid configuration.json
|
10
|
-
|
11
|
-
# configuration.json
|
12
|
-
|
13
|
-
{
|
14
|
-
"servers": ["server1","server2"],
|
15
|
-
"ssh-auth": "key",
|
16
|
-
"run_list": ["role[name]"],
|
17
|
-
"owner": "[USER]",
|
18
|
-
"group": "[GROUP]"
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
## Requirements
|
24
|
-
|
25
|
-
* Ruby
|
26
|
-
* RubyGems
|
27
|
-
* net/ssh
|
28
|
-
|
29
|
-
## Install
|
30
|
-
|
31
|
-
gem install solid
|
32
|
-
|
33
|
-
## Download Source
|
34
|
-
|
35
|
-
http://github.com/jackhq/solid
|
36
|
-
|
37
|
-
|
38
|
-
## What is a dna.json file?
|
39
|
-
|
40
|
-
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
|
41
|
-
|
42
|
-
{
|
43
|
-
"servers": ["server1","server2"],
|
44
|
-
"ssh-auth": "key",
|
45
|
-
"run_list": ["role[name]"],
|
46
|
-
"owner": "[USER]",
|
47
|
-
"group": "[GROUP]"
|
48
|
-
}
|
49
|
-
|
50
|
-
## How to use
|
51
|
-
|
52
|
-
* Create your dna.json file
|
53
|
-
|
54
|
-
* Make sure it has the following root attributes:
|
55
|
-
|
56
|
-
* servers - array of servers
|
57
|
-
* ssh-auth - (key|pwd) - type ssh authentication
|
58
|
-
* key - if ssh authentication is key based
|
59
|
-
* password - if ssh authentication is pwd based
|
60
|
-
* port
|
61
|
-
|
62
|
-
* Execute
|
63
|
-
|
64
|
-
solid dna.json
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
## Note on Patches/Pull Requests
|
69
|
-
|
70
|
-
* Fork the project.
|
71
|
-
* Make your feature addition or bug fix.
|
72
|
-
* Add tests for it. This is important so I don't break it in a
|
73
|
-
future version unintentionally.
|
74
|
-
* Commit, do not mess with rakefile, version, or history.
|
75
|
-
(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)
|
76
|
-
* Send me a pull request. Bonus points for topic branches.
|
77
|
-
|
78
|
-
== Copyright
|
79
|
-
|
80
|
-
Copyright (c) 2010 Thing-3. See LICENSE for details.
|
data/lib/solid/constants.rb
DELETED
@@ -1,30 +0,0 @@
|
|
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
DELETED
@@ -1,35 +0,0 @@
|
|
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
DELETED
data/lib/solid/ssh.rb
DELETED
data/spec/fixtures/dna.json
DELETED
data/spec/fixtures/error.json
DELETED
data/spec/fixtures/no_ssh.json
DELETED
data/spec/lib/solid/chef_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
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
|
@@ -1,40 +0,0 @@
|
|
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
DELETED
data/spec/spec_helper.rb
DELETED