ona 0.0.1
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/ona +22 -0
- data/lib/ona.rb +3 -0
- data/lib/ona_cli.rb +84 -0
- data/lib/ona_server.rb +48 -0
- data/lib/ona_stack.rb +44 -0
- data/ona.gemspec +60 -0
- data/test/helper.rb +10 -0
- data/test/test_ona.rb +7 -0
- metadata +95 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 kazuyoshi tlacaelel
|
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,17 @@
|
|
1
|
+
= ona
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(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)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 kazuyoshi tlacaelel. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ona"
|
8
|
+
gem.summary = %Q{Ona -- Deployment symplified.}
|
9
|
+
gem.description = %Q{Simple shell for deployment.}
|
10
|
+
gem.email = "kazu.dev@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/ktlacaelel/ona"
|
12
|
+
gem.authors = ["kazuyoshi tlacaelel"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "ona #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/ona
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'readline'
|
5
|
+
require 'ona'
|
6
|
+
|
7
|
+
stack = Ona::Stack.new
|
8
|
+
eval File.read 'Onafile'
|
9
|
+
cli = Ona::Cli.new(stack)
|
10
|
+
|
11
|
+
loop do
|
12
|
+
line = Readline.readline('Ona> ', true)
|
13
|
+
if line == 'quit'
|
14
|
+
puts 'bye.'
|
15
|
+
break
|
16
|
+
end
|
17
|
+
cli.ls if line == 'ls'
|
18
|
+
cli.help if line == 'help'
|
19
|
+
cli.list line if line =~ /list/
|
20
|
+
cli.setup line if line =~ /setup/
|
21
|
+
cli.deploy line if line =~ /deploy/
|
22
|
+
end
|
data/lib/ona.rb
ADDED
data/lib/ona_cli.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
module Ona
|
2
|
+
|
3
|
+
class Cli
|
4
|
+
|
5
|
+
FRINED_ACTIONS = %q{deploy setup}
|
6
|
+
LONE_ACTIONS = %q{list ls}
|
7
|
+
|
8
|
+
def initialize(stack)
|
9
|
+
@stack = stack
|
10
|
+
end
|
11
|
+
|
12
|
+
def selected_servers string
|
13
|
+
@stack.find_all(*string.scan(/\d+/).map { |id| id.to_i })
|
14
|
+
end
|
15
|
+
|
16
|
+
def unknown_command
|
17
|
+
puts 'Unknown command.'
|
18
|
+
help
|
19
|
+
end
|
20
|
+
|
21
|
+
def help
|
22
|
+
puts "
|
23
|
+
Ona -- Deployment simplified.
|
24
|
+
|
25
|
+
help # show this help
|
26
|
+
|
27
|
+
ls # short list for available servers
|
28
|
+
list # detailed list for available servers
|
29
|
+
|
30
|
+
deploy 1 # Deploy a specific server
|
31
|
+
deploy 1 2 3 # Deploy servers with ids: 1 2 and 3
|
32
|
+
|
33
|
+
setup 1 # Upload ssh-keys and bootstrap server
|
34
|
+
setup 1 2 3 # Setup servers with ids: 1 2 and 3
|
35
|
+
|
36
|
+
quit # Setup servers with ids: 1 2 and 3
|
37
|
+
|
38
|
+
"
|
39
|
+
end
|
40
|
+
|
41
|
+
def list string
|
42
|
+
selected_servers(string).each do |server|
|
43
|
+
puts server.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def ls
|
48
|
+
@stack.to_a.each do |server|
|
49
|
+
puts server.to_short_s
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def system string
|
54
|
+
puts string
|
55
|
+
end
|
56
|
+
|
57
|
+
def deploy string
|
58
|
+
selected_servers(string).each do |server|
|
59
|
+
system server.deploy
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup string
|
64
|
+
install_ssh_keys string
|
65
|
+
bootstrap string
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
def bootstrap string
|
71
|
+
selected_servers(string).each do |server|
|
72
|
+
system server.bootstrap
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def install_ssh_keys string
|
77
|
+
selected_servers(string).each do |server|
|
78
|
+
system server.setup_ssh
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
data/lib/ona_server.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Ona
|
2
|
+
|
3
|
+
class Server
|
4
|
+
|
5
|
+
attr_accessor :id, :role, :ip, :pass, :desc, :dna
|
6
|
+
|
7
|
+
def load_block id, &block
|
8
|
+
@id = id
|
9
|
+
yield(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup_ssh
|
13
|
+
"rake upload_ssh_key server=#{ip} pass=#{pass} key=#{local_key}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def bootstrap
|
17
|
+
"rake bootstrap server=root@#{ip}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def deploy
|
21
|
+
"rake cook server=root@#{ip} dna=#{dna} instance_role=#{role}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_short_s
|
25
|
+
"#{id}".ljust(5) + "#{desc}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
29
|
+
"
|
30
|
+
#{id} - #{desc}
|
31
|
+
|
32
|
+
Id #{id}
|
33
|
+
Ip #{ip}
|
34
|
+
Dna #{dna}
|
35
|
+
Role #{role}
|
36
|
+
Password #{pass}
|
37
|
+
|
38
|
+
ssh root@#{ip}
|
39
|
+
"
|
40
|
+
end
|
41
|
+
|
42
|
+
def local_key
|
43
|
+
File.join(ENV['HOME'], '.ssh/id_rsa.pub')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/ona_stack.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Ona
|
2
|
+
|
3
|
+
class Stack
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@list = []
|
7
|
+
@id = 0
|
8
|
+
@rack_machine = './'
|
9
|
+
end
|
10
|
+
|
11
|
+
def append &block
|
12
|
+
@id += 1
|
13
|
+
server = Server.new
|
14
|
+
server.load_block(@id, &block)
|
15
|
+
@list << server
|
16
|
+
end
|
17
|
+
|
18
|
+
def rack_machine path
|
19
|
+
@rack_machine = path
|
20
|
+
end
|
21
|
+
|
22
|
+
def find num
|
23
|
+
@list.each do |server|
|
24
|
+
return server if server.id == num
|
25
|
+
end
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_all *args
|
30
|
+
args.map { |id| find id }.compact
|
31
|
+
end
|
32
|
+
|
33
|
+
def exists? num
|
34
|
+
return false if find(num).nil?
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_a
|
39
|
+
@list
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/ona.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
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{ona}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["kazuyoshi tlacaelel"]
|
12
|
+
s.date = %q{2010-07-27}
|
13
|
+
s.default_executable = %q{ona}
|
14
|
+
s.description = %q{Simple shell for deployment.}
|
15
|
+
s.email = %q{kazu.dev@gmail.com}
|
16
|
+
s.executables = ["ona"]
|
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/ona",
|
29
|
+
"lib/ona.rb",
|
30
|
+
"lib/ona_cli.rb",
|
31
|
+
"lib/ona_server.rb",
|
32
|
+
"lib/ona_stack.rb",
|
33
|
+
"ona.gemspec",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_ona.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/ktlacaelel/ona}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{Ona -- Deployment symplified.}
|
42
|
+
s.test_files = [
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/test_ona.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/test/helper.rb
ADDED
data/test/test_ona.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ona
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- kazuyoshi tlacaelel
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-27 00:00:00 -05:00
|
19
|
+
default_executable: ona
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thoughtbot-shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Simple shell for deployment.
|
36
|
+
email: kazu.dev@gmail.com
|
37
|
+
executables:
|
38
|
+
- ona
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/ona
|
52
|
+
- lib/ona.rb
|
53
|
+
- lib/ona_cli.rb
|
54
|
+
- lib/ona_server.rb
|
55
|
+
- lib/ona_stack.rb
|
56
|
+
- ona.gemspec
|
57
|
+
- test/helper.rb
|
58
|
+
- test/test_ona.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/ktlacaelel/ona
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Ona -- Deployment symplified.
|
93
|
+
test_files:
|
94
|
+
- test/helper.rb
|
95
|
+
- test/test_ona.rb
|