orchestra 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in orchestra.gemspec
4
+ gemspec
5
+
6
+ gem 'debugger'
7
+ gem 'rake'
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ orchestra (0.0.1)
5
+ mixlib-cli
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ columnize (0.3.6)
11
+ debugger (1.2.0)
12
+ columnize (>= 0.3.1)
13
+ debugger-linecache (~> 1.1.1)
14
+ debugger-ruby_core_source (~> 1.1.3)
15
+ debugger-linecache (1.1.2)
16
+ debugger-ruby_core_source (>= 1.1.1)
17
+ debugger-ruby_core_source (1.1.3)
18
+ mixlib-cli (1.2.2)
19
+ rake (0.9.2.2)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ debugger
26
+ orchestra!
27
+ rake
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Anthony Scalisi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Orchestra
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'orchestra'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install orchestra
18
+
19
+ ## Usage
20
+
21
+ $ orchestra -P update_keys -H web1,web2,db1
22
+
23
+
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/orchestra ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'orchestra'
4
+ Orchestra::CLI.new.execute
@@ -0,0 +1,20 @@
1
+ set :hosts, ["web1", "web2"]
2
+
3
+ task :helloworld do
4
+ puts "helloworld"
5
+ # run('echo hello world!')
6
+ end
7
+
8
+ task :ls_root do
9
+ puts "ls_root"
10
+ # sudo('ls -l /root')
11
+ end
12
+
13
+ task :all do
14
+ helloworld
15
+ ls_root
16
+ end
17
+
18
+ # $orchestra task
19
+ # $orchestra -P task
20
+ # $orchestra task helloworld -H web1
@@ -0,0 +1,60 @@
1
+ require 'mixlib/cli'
2
+ require 'ruby-debug'
3
+
4
+ module Orchestra
5
+ class CLI
6
+ include ::Mixlib::CLI
7
+
8
+ option :parallel,
9
+ :short => "-P",
10
+ :long => "--parallel",
11
+ :boolean => true,
12
+ :required => false,
13
+ :description => "Use concurrent connections for SSH"
14
+
15
+ option :hosts,
16
+ :short => "-H HOSTS",
17
+ :long => "--host HOSTS",
18
+ :required => false,
19
+ :description => "Speciify by hand the hosts to run Orchestra on. Take over any other configurations.",
20
+ :proc => Proc.new { |l| l.split(',') }
21
+
22
+ option :partition,
23
+ :short => "-f PARTITION",
24
+ :long => "--file PARTITION",
25
+ :default => 'partition.rb',
26
+ :required => false,
27
+ :description => "File to read for the task(s) to be executed."
28
+
29
+ def execute
30
+ $stdout.sync = true
31
+ parse_options
32
+
33
+ play_partition!
34
+ end
35
+
36
+ private
37
+
38
+ def set_tasks(args = ARGV)
39
+ config[:tasks] ||= []
40
+ args.each do |arg|
41
+ break if arg =~ /^-/
42
+ config[:tasks] << arg
43
+ end
44
+ config[:tasks]
45
+ end
46
+
47
+ def parse_options
48
+ super
49
+ set_tasks
50
+ end
51
+
52
+ def play_partition!
53
+ orchestra_configuration.play_partition!
54
+ end
55
+
56
+ def orchestra_configuration
57
+ @orchestra_configuration ||= ::Orchestra::Configuration.new(config)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,4 @@
1
+ module Orchestra
2
+ class Command
3
+ end
4
+ end
@@ -0,0 +1,40 @@
1
+ module Orchestra
2
+ class Configuration
3
+ attr_reader :config
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ end
8
+
9
+ def play_partition!
10
+ load_partition!
11
+
12
+ run_tasks
13
+ end
14
+
15
+ def run_tasks
16
+ config[:tasks].each do |task_name|
17
+ @tasks[task_name.to_sym].call if @tasks[task_name.to_sym]
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def set(variable_name, value)
24
+ @variables ||= {}
25
+ @variables[variable_name] = value
26
+ end
27
+
28
+ def task(task_name, &block)
29
+ @tasks ||= {}
30
+ @tasks[task_name.to_sym] = block
31
+ end
32
+
33
+ def load_partition!
34
+ return if @loaded
35
+
36
+ instance_eval(File.read(config[:partition]))
37
+ @loaded = true
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ module Orchestra
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+ PRE = nil
7
+
8
+ def self.to_s
9
+ [MAJOR, MINOR, PATCH, PRE].compact.join('.')
10
+ end
11
+ end unless defined?(::Orchestra::VERSION)
12
+ ::Orchestra::VERSION
13
+ end
data/lib/orchestra.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Orchestra
2
+ autoload :VERSION, 'orchestra/version'
3
+ autoload :CLI, 'orchestra/cli'
4
+ autoload :Configuration, 'orchestra/configuration'
5
+ end
data/orchestra.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'orchestra/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "orchestra"
8
+ gem.version = Orchestra::VERSION
9
+ gem.authors = ["Anthony Scalisi", "Jean-Richard Lai"]
10
+ gem.email = ["scalisi.a@gmail.com", "jrichardlai@gmail.com"]
11
+ gem.description = %q{SSH toolkit for application deployment and devops tasks.}
12
+ gem.summary = %q{Lightning fast deployment.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_dependency "mixlib-cli"
20
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orchestra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anthony Scalisi
9
+ - Jean-Richard Lai
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-11-02 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mixlib-cli
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ description: SSH toolkit for application deployment and devops tasks.
32
+ email:
33
+ - scalisi.a@gmail.com
34
+ - jrichardlai@gmail.com
35
+ executables:
36
+ - orchestra
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - bin/orchestra
46
+ - examples/hello_world.rb
47
+ - lib/orchestra.rb
48
+ - lib/orchestra/cli.rb
49
+ - lib/orchestra/command.rb
50
+ - lib/orchestra/configuration.rb
51
+ - lib/orchestra/version.rb
52
+ - orchestra.gemspec
53
+ homepage: ''
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ segments:
66
+ - 0
67
+ hash: -1031003115086724039
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ segments:
75
+ - 0
76
+ hash: -1031003115086724039
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.24
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Lightning fast deployment.
83
+ test_files: []