solid 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Thing-3
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = solid
2
+
3
+ A Net/SSH library that connects to application servers and executes a dna.json on the server with chef-solo.
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 uris or ip addresses
35
+ * ssh-auth - (key|pwd) - type ssh authentication
36
+ * key - if ssh authentication is key based
37
+ * pwd - if ssh authentication is pwd based
38
+
39
+ * Execute
40
+
41
+ solid dna.json
42
+
43
+
44
+
45
+
46
+ == Note on Patches/Pull Requests
47
+
48
+ * Fork the project.
49
+ * Make your feature addition or bug fix.
50
+ * Add tests for it. This is important so I don't break it in a
51
+ future version unintentionally.
52
+ * Commit, do not mess with rakefile, version, or history.
53
+ (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)
54
+ * Send me a pull request. Bonus points for topic branches.
55
+
56
+ == Copyright
57
+
58
+ Copyright (c) 2010 Thing-3. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "solid"
8
+ gem.summary = %Q{ssh deployment application}
9
+ gem.description = %Q{ssh deployment application}
10
+ gem.email = "thing3@jackhq.com"
11
+ gem.homepage = "http://github.com/jackhq/solid"
12
+ gem.authors = ["Thing-3"]
13
+ gem.files.include FileList["lib/solid/*"]
14
+
15
+ gem.add_dependency "net-ssh", ">= 0"
16
+ gem.add_dependency "crack", ">= 0"
17
+ gem.add_dependency "json_pure", ">= 0"
18
+
19
+
20
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+ rescue LoadError
42
+ task :rcov do
43
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
+ end
45
+ end
46
+
47
+ task :test => :check_dependencies
48
+
49
+ task :default => :test
50
+
51
+ require 'rake/rdoctask'
52
+ Rake::RDocTask.new do |rdoc|
53
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "solid #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
data/bin/solid ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/solid'
7
+
8
+ args = ARGV.dup
9
+
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/chef.rb ADDED
@@ -0,0 +1,50 @@
1
+ module Solid
2
+
3
+ class Chef
4
+
5
+ def initialize(server, user, options = {})
6
+ @server = server
7
+ @user = user
8
+ @options = options.merge(:port => 2222)
9
+ end
10
+
11
+ def install
12
+ unless installed?
13
+ Net::SSH.start(@server, @user, @options) do |ssh|
14
+ puts "installing..."
15
+ puts ssh.exec! sudo_cmd + "apt-get update -y"
16
+ ssh.exec! "sudo apt-get install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential git-core xfsprogs -y"
17
+ ssh.exec! "wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz && tar zxf rubygems-1.3.7.tgz && cd rubygems-1.3.7 && sudo ruby setup.rb && sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem"
18
+ ssh.exec! "sudo gem update --system"
19
+ puts ssh.exec! "sudo gem install chef --no-ri --no-rdoc"
20
+ end
21
+ end
22
+ end
23
+
24
+ def installed?
25
+ result = false
26
+ Net::SSH.start(@server, @user, @options) do |ssh|
27
+ puts "checking if installed"
28
+ result = ssh.exec!("which chef-solo")
29
+ end
30
+ result =~ /chef-solo/
31
+ end
32
+
33
+ def solo(dna, cookbooks)
34
+ puts @options.inspect
35
+ Net::SSH.start(@server, @user, @options) do |ssh|
36
+ puts "deploying..."
37
+ ssh.exec!("echo \"#{dna.to_json.gsub('"','\"')}\" > dna.json")
38
+ puts ssh.exec!(sudo_cmd + " chef-solo -l debug -j dna.json -r #{cookbooks}")
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def sudo_cmd
45
+ @options[:password] ? "echo #{@options[:password]} | sudo -S " : "sudo "
46
+ end
47
+ end
48
+
49
+
50
+ end
@@ -0,0 +1,49 @@
1
+ module Solid
2
+
3
+ module Commands
4
+
5
+ class << self
6
+
7
+ def deploy(dna_file)
8
+ dna = Crack::JSON.parse(get_dna(dna_file))
9
+ dna["servers"].each do |s|
10
+ run(s, dna)
11
+ end
12
+ end
13
+
14
+ def rollback(dna_file)
15
+ dna = Crack::JSON.parse(get_dna(dna_file))
16
+ dna.merge!(:action => 'rollback')
17
+ dna["servers"].each do |s|
18
+ run(s, dna)
19
+ end
20
+
21
+ end
22
+
23
+ def logs
24
+ puts "Comming Soon!"
25
+ end
26
+
27
+
28
+
29
+
30
+ private
31
+
32
+ def run(s, dna)
33
+ chef = Chef.new(s, dna["user"], dna['ssh-auth'] == 'key' ? { :keys => dna["key"] } : { :password => dna["password"] })
34
+ chef.install
35
+ chef.solo dna, dna["cookbooks"]
36
+ end
37
+
38
+
39
+ def get_dna(dna_file)
40
+ dna = ""
41
+ File.open(dna_file, 'r') do |f|
42
+ dna = f.read
43
+ end
44
+ dna
45
+ end
46
+
47
+ end
48
+ end
49
+ end
data/lib/solid.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'net/ssh'
2
+ require 'crack'
3
+ require 'json/pure'
4
+
5
+ require File.dirname(__FILE__) + '/solid/chef'
6
+ require File.dirname(__FILE__) + '/solid/commands'
data/solid.gemspec ADDED
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{solid}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Thing-3"]
12
+ s.date = %q{2010-05-26}
13
+ s.default_executable = %q{solid}
14
+ s.description = %q{ssh deployment application}
15
+ s.email = %q{thing3@jackhq.com}
16
+ s.executables = ["solid"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/solid",
29
+ "lib/solid.rb",
30
+ "lib/solid/chef.rb",
31
+ "lib/solid/commands.rb",
32
+ "solid.gemspec",
33
+ "test/helper.rb",
34
+ "test/test_solid.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/jackhq/solid}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.6}
40
+ s.summary = %q{ssh deployment application}
41
+ s.test_files = [
42
+ "test/helper.rb",
43
+ "test/test_solid.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
52
+ s.add_runtime_dependency(%q<crack>, [">= 0"])
53
+ s.add_runtime_dependency(%q<json_pure>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<net-ssh>, [">= 0"])
56
+ s.add_dependency(%q<crack>, [">= 0"])
57
+ s.add_dependency(%q<json_pure>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<net-ssh>, [">= 0"])
61
+ s.add_dependency(%q<crack>, [">= 0"])
62
+ s.add_dependency(%q<json_pure>, [">= 0"])
63
+ end
64
+ end
65
+
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'solid'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSolid < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solid
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Thing-3
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-26 00:00:00 -04:00
18
+ default_executable: solid
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: net-ssh
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: crack
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: json_pure
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id003
56
+ description: ssh deployment application
57
+ email: thing3@jackhq.com
58
+ executables:
59
+ - solid
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - LICENSE
64
+ - README.rdoc
65
+ files:
66
+ - .document
67
+ - .gitignore
68
+ - LICENSE
69
+ - README.rdoc
70
+ - Rakefile
71
+ - VERSION
72
+ - bin/solid
73
+ - lib/solid.rb
74
+ - lib/solid/chef.rb
75
+ - lib/solid/commands.rb
76
+ - solid.gemspec
77
+ - test/helper.rb
78
+ - test/test_solid.rb
79
+ has_rdoc: true
80
+ homepage: http://github.com/jackhq/solid
81
+ licenses: []
82
+
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.6
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: ssh deployment application
109
+ test_files:
110
+ - test/helper.rb
111
+ - test/test_solid.rb