tele 0.1.2 → 0.1.3
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 +11 -2
- data/bin/tele +41 -32
- data/tele.gemspec +1 -1
- data/test/tele.rb +25 -41
- metadata +5 -7
data/README
CHANGED
@@ -4,7 +4,10 @@ NAME
|
|
4
4
|
tele -- Provisioning at a distance.
|
5
5
|
|
6
6
|
SYNOPSIS
|
7
|
-
tele
|
7
|
+
tele init
|
8
|
+
tele deploy [-d path] [-s server]
|
9
|
+
tele tail
|
10
|
+
tele -h
|
8
11
|
|
9
12
|
DESCRIPTION
|
10
13
|
Tele is a small provisioning framework that allows you to run bash
|
@@ -62,6 +65,9 @@ DESCRIPTION
|
|
62
65
|
configuration files. You can also use the environment variable
|
63
66
|
TELE_HOME.
|
64
67
|
|
68
|
+
-s server
|
69
|
+
Allows you to specify a server you want to deploy.
|
70
|
+
|
65
71
|
init
|
66
72
|
Copies a .tele template to the current directory.
|
67
73
|
|
@@ -106,5 +112,8 @@ USAGE
|
|
106
112
|
# Run tele deploy
|
107
113
|
$ tele deploy
|
108
114
|
|
115
|
+
# Run tele deploy only for server1
|
116
|
+
$ tele deploy -s server1
|
117
|
+
|
109
118
|
INSTALLATION
|
110
|
-
$ gem install tele
|
119
|
+
$ gem install tele
|
data/bin/tele
CHANGED
@@ -38,7 +38,7 @@ def layout
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def servers
|
41
|
-
layout["servers"]
|
41
|
+
$servers ||= layout["servers"]
|
42
42
|
end
|
43
43
|
|
44
44
|
def roles
|
@@ -49,30 +49,34 @@ def run(server, recipe)
|
|
49
49
|
script = path("recipes", "#{recipe}.sh")
|
50
50
|
|
51
51
|
if File.exist?(script)
|
52
|
-
|
52
|
+
IO.popen(ssh(server, SSH_OPTIONS), "r+") do |io|
|
53
|
+
io.puts(File.read(script))
|
54
|
+
io.close_write
|
55
|
+
|
56
|
+
while line = io.gets
|
57
|
+
yield(line)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
53
61
|
$?.exitstatus
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
57
65
|
out = Module.new do
|
58
|
-
def self.server
|
59
|
-
|
66
|
+
def self.recipe(server, recipe)
|
67
|
+
print "#{server}/#{recipe}: "
|
60
68
|
end
|
61
69
|
|
62
70
|
def self.error
|
63
|
-
|
71
|
+
print "\033[01;31mERROR\033[00m"
|
64
72
|
end
|
65
73
|
|
66
74
|
def self.ok
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.log(match)
|
71
|
-
puts "\033[1;30m#{match[:date]} \033[1;33m#{match[:who]}\033[00m #{match[:message]}"
|
75
|
+
print "\033[01;32mOK\033[00m"
|
72
76
|
end
|
73
77
|
|
74
78
|
def self.unknown
|
75
|
-
|
79
|
+
print "\033[1;33m?\033[00m"
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
@@ -86,9 +90,17 @@ commands = Clap.run ARGV,
|
|
86
90
|
},
|
87
91
|
"-d" => lambda { |path|
|
88
92
|
ENV["TELE_HOME"] = File.join(Dir.pwd, path)
|
93
|
+
},
|
94
|
+
"-s" => lambda { |server|
|
95
|
+
unless servers.has_key?(server)
|
96
|
+
$stderr.puts "Unknown server: #{server}"
|
97
|
+
exit 1
|
98
|
+
end
|
99
|
+
|
100
|
+
servers.delete_if { |s, _| s != server }
|
89
101
|
}
|
90
102
|
|
91
|
-
Clap.run commands,
|
103
|
+
commands = Clap.run commands,
|
92
104
|
"init" => lambda {
|
93
105
|
source = File.expand_path("../templates/.tele", File.dirname(__FILE__))
|
94
106
|
target = File.expand_path(Dir.pwd)
|
@@ -96,19 +108,6 @@ Clap.run commands,
|
|
96
108
|
%x{cp -r #{source} #{target}}
|
97
109
|
|
98
110
|
%x{find #{target} -name .empty -print0 | xargs rm}
|
99
|
-
},
|
100
|
-
|
101
|
-
"tail" => lambda {
|
102
|
-
$stdout.sync = true
|
103
|
-
|
104
|
-
parser = %r{^(?<date>.* \d\d:\d\d:\d\d) \w+ tele/(?<who>.*)\[\d+\]: (?<message>.*)$}
|
105
|
-
|
106
|
-
IO.popen("tail -0 -f /var/log/system.log /var/log/syslog 2>/dev/null") do |io|
|
107
|
-
while line = io.gets
|
108
|
-
next unless match = parser.match(line)
|
109
|
-
out.log(match)
|
110
|
-
end
|
111
|
-
end
|
112
111
|
}
|
113
112
|
|
114
113
|
unless File.directory?(path)
|
@@ -122,19 +121,24 @@ SSH_OPTIONS = [
|
|
122
121
|
"-S", "/tmp/ssh-%r@%h:%p",
|
123
122
|
]
|
124
123
|
|
125
|
-
Clap.run commands,
|
124
|
+
commands = Clap.run commands,
|
126
125
|
"deploy" => lambda {
|
127
126
|
servers.each do |server, _|
|
128
127
|
IO.popen(ssh(server, SSH_OPTIONS + %w[-Mq]), "w")
|
129
128
|
end
|
130
129
|
|
131
130
|
servers.each do |server, assigned_roles|
|
132
|
-
out.server(server)
|
133
|
-
|
134
131
|
recipes_for(assigned_roles).each do |recipe|
|
135
|
-
|
132
|
+
out.recipe(server, recipe)
|
133
|
+
|
134
|
+
# first = true
|
136
135
|
|
137
|
-
|
136
|
+
result = run(server, recipe) do |line|
|
137
|
+
print line
|
138
|
+
out.recipe(server, recipe) # unless first
|
139
|
+
end
|
140
|
+
|
141
|
+
case result
|
138
142
|
when nil
|
139
143
|
out.unknown
|
140
144
|
when 0
|
@@ -142,8 +146,13 @@ Clap.run commands,
|
|
142
146
|
else
|
143
147
|
out.error
|
144
148
|
end
|
145
|
-
end
|
146
149
|
|
147
|
-
|
150
|
+
print "\n"
|
151
|
+
end
|
148
152
|
end
|
149
153
|
}
|
154
|
+
|
155
|
+
unless commands.empty?
|
156
|
+
$stderr.puts "Error: unrecognized parameter: #{commands.join(" ")}"
|
157
|
+
exit 1
|
158
|
+
end
|
data/tele.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "tele"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.3"
|
4
4
|
s.summary = "Provisioning at a distance"
|
5
5
|
s.description = "Tele is a small provisioning framework that allows you to run bash scripts on remote servers over SSH."
|
6
6
|
s.authors = ["Damian Janowski", "Michel Martens"]
|
data/test/tele.rb
CHANGED
@@ -31,7 +31,7 @@ test "`tele deploy` displays missing recipes" do
|
|
31
31
|
out, err = tele("deploy", "-d", "test/.tele.missing-recipes")
|
32
32
|
|
33
33
|
assert out =~ /db-1/
|
34
|
-
assert out =~ /redis
|
34
|
+
assert out =~ /redis.*: .*\?/
|
35
35
|
end
|
36
36
|
|
37
37
|
test "`tele deploy` displays layout" do
|
@@ -39,30 +39,37 @@ test "`tele deploy` displays layout" do
|
|
39
39
|
|
40
40
|
assert err.empty?
|
41
41
|
|
42
|
-
parts = out.split("\n
|
42
|
+
parts = out.split("\n")
|
43
43
|
|
44
|
-
assert parts[0] =~
|
45
|
-
assert parts[
|
46
|
-
assert parts[
|
47
|
-
assert parts[0] =~ /unicorn/
|
44
|
+
assert parts[0] =~ %r[^app-1/redis]
|
45
|
+
assert parts[1] =~ %r[^app-1/ruby]
|
46
|
+
assert parts[2] =~ %r[^app-1/unicorn]
|
48
47
|
|
49
|
-
assert parts[
|
50
|
-
assert parts[1] =~ /redis/
|
48
|
+
assert parts[3] =~ %r[^app-2/redis]
|
51
49
|
|
52
|
-
assert parts[
|
53
|
-
assert parts[
|
54
|
-
assert parts[
|
55
|
-
assert parts[2] =~ /unicorn/
|
50
|
+
assert parts[4] =~ %r[app-3/redis]
|
51
|
+
assert parts[5] =~ %r[app-3/ruby]
|
52
|
+
assert parts[6] =~ %r[app-3/unicorn]
|
56
53
|
end
|
57
54
|
|
58
55
|
test "`tele deploy` runs recipes" do
|
59
56
|
out, err = tele("deploy", "-d", "test/.tele.simple")
|
60
57
|
|
61
|
-
assert out =~
|
62
|
-
assert out =~ /
|
63
|
-
assert out =~ /redis
|
58
|
+
assert out =~ %r[^staging/cassandra.* .*ERROR]
|
59
|
+
assert out =~ %r[^staging/redis.* Installed]
|
60
|
+
assert out =~ %r[^staging/redis.* .*OK]
|
64
61
|
end
|
65
62
|
|
63
|
+
test "`tele deploy -s production` runs only production recipes" do
|
64
|
+
out, err = tele("deploy", "-d", "test/.tele.multi", "-s", "production")
|
65
|
+
|
66
|
+
assert out !~ /staging/
|
67
|
+
|
68
|
+
assert out =~ %r[production/cassandra.*: .*ERROR]
|
69
|
+
assert out =~ %r[production/redis.*: .*OK]
|
70
|
+
end
|
71
|
+
|
72
|
+
|
66
73
|
test "`tele deploy` doesn't run the same recipe twice in a single server" do
|
67
74
|
out, err = tele("deploy", "-d", "test/.tele.simple")
|
68
75
|
|
@@ -89,31 +96,8 @@ test "`tele init`" do
|
|
89
96
|
end
|
90
97
|
end
|
91
98
|
|
92
|
-
test "
|
93
|
-
out, err = tele("
|
94
|
-
|
95
|
-
assert `tail -n 20 /var/log/syslog /var/log/system.log 2>/dev/null`[%r{tele/staging/cassandra.*Can't find Cassandra}]
|
96
|
-
end
|
97
|
-
|
98
|
-
test "`tele tail` shows Tele logs" do
|
99
|
-
log = []
|
100
|
-
tailing = false
|
101
|
-
|
102
|
-
t = Thread.new do
|
103
|
-
Open3.popen3("#{root "bin/tele"} tail") do |_, out, _, _|
|
104
|
-
tailing = true
|
105
|
-
while line = out.gets
|
106
|
-
log << line
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
until tailing; end
|
112
|
-
|
113
|
-
tele("deploy", "-d", "test/.tele.simple")
|
114
|
-
|
115
|
-
t.kill
|
99
|
+
test "`tele foobar` shouts an error" do
|
100
|
+
out, err = tele("foobar", "-d", "test/.tele.simple")
|
116
101
|
|
117
|
-
|
118
|
-
assert log[0] =~ %r{staging/cassandra.*Can't find Cassandra}
|
102
|
+
assert err.include?("Error: unrecognized parameter: foobar")
|
119
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tele
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
default_executable:
|
13
|
+
date: 2012-01-17 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: clap
|
18
|
-
requirement: &
|
17
|
+
requirement: &70301175305080 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ! '>='
|
@@ -23,7 +22,7 @@ dependencies:
|
|
23
22
|
version: '0'
|
24
23
|
type: :runtime
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *70301175305080
|
27
26
|
description: Tele is a small provisioning framework that allows you to run bash scripts
|
28
27
|
on remote servers over SSH.
|
29
28
|
email:
|
@@ -43,7 +42,6 @@ files:
|
|
43
42
|
- templates/.tele/recipes/.empty
|
44
43
|
- tele.gemspec
|
45
44
|
- test/tele.rb
|
46
|
-
has_rdoc: true
|
47
45
|
homepage: http://github.com/djanowski/tele
|
48
46
|
licenses: []
|
49
47
|
post_install_message:
|
@@ -64,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
62
|
version: '0'
|
65
63
|
requirements: []
|
66
64
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.8.10
|
68
66
|
signing_key:
|
69
67
|
specification_version: 3
|
70
68
|
summary: Provisioning at a distance
|