tele 0.1.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +32 -31
- data/bin/tele +21 -17
- data/tele.gemspec +1 -1
- data/templates/.tele/layout.json +3 -1
- data/test/tele.rb +17 -19
- metadata +5 -5
data/README
CHANGED
@@ -5,12 +5,12 @@ NAME
|
|
5
5
|
|
6
6
|
SYNOPSIS
|
7
7
|
tele init
|
8
|
-
tele deploy [-d path]
|
9
|
-
tele exec [-d path]
|
8
|
+
tele deploy environment [-d path]
|
9
|
+
tele exec environment command [-d path]
|
10
10
|
tele -h
|
11
11
|
|
12
12
|
DESCRIPTION
|
13
|
-
Tele is a small provisioning framework that allows you to run
|
13
|
+
Tele is a small provisioning framework that allows you to run shell
|
14
14
|
scripts on remote servers over SSH. It uses your own SSH, not a Ruby
|
15
15
|
version, so you can profit from your settings and public/private keys.
|
16
16
|
|
@@ -26,34 +26,38 @@ DESCRIPTION
|
|
26
26
|
charge of creating them.
|
27
27
|
|
28
28
|
layout.json
|
29
|
-
The server layout, with the available roles and servers. Example:
|
29
|
+
The server layout, with the available roles, environments and servers. Example:
|
30
30
|
|
31
31
|
{
|
32
32
|
"roles": {
|
33
|
-
"db":
|
33
|
+
"db": ["redis"],
|
34
34
|
"web": ["ruby", "unicorn"],
|
35
|
-
"app": ["db", "web"]
|
36
35
|
},
|
37
36
|
|
38
|
-
"
|
39
|
-
"
|
40
|
-
|
41
|
-
|
37
|
+
"environments": {
|
38
|
+
"staging": {
|
39
|
+
"ec2-small": ["db", "web"]
|
40
|
+
},
|
41
|
+
|
42
|
+
"production": {
|
43
|
+
"linode-1": ["db"],
|
44
|
+
"linode-2": ["web"]
|
45
|
+
}
|
42
46
|
}
|
43
47
|
}
|
44
48
|
|
45
49
|
The key "roles" stores a tree, where each key is mapped
|
46
50
|
to an array of recipes. The leaves--those elements in the tree that
|
47
51
|
are not present as keys--are the ones that have to be available as
|
48
|
-
|
49
|
-
while "db"
|
52
|
+
shell scripts. In this example, both "redis" and "unicorn" are leaves,
|
53
|
+
while "db" and "web" are recipes composed of other recipes.
|
50
54
|
|
51
|
-
The key "
|
52
|
-
|
55
|
+
The key "environments" stores a map of environments to servers to roles.
|
56
|
+
Server names must correspond with an entry in .tele/ssh_config.
|
53
57
|
|
54
58
|
ssh_config
|
55
|
-
Configuration file for the SSH connection.
|
56
|
-
|
59
|
+
Configuration file for the SSH connection.
|
60
|
+
Check ssh_config(5) for more information.
|
57
61
|
|
58
62
|
The following options are available:
|
59
63
|
|
@@ -65,18 +69,16 @@ DESCRIPTION
|
|
65
69
|
configuration files. You can also use the environment variable
|
66
70
|
TELE_HOME.
|
67
71
|
|
68
|
-
-s server
|
69
|
-
Allows you to specify a server you want to deploy.
|
70
|
-
|
71
72
|
init
|
72
73
|
Copies a .tele template to the current directory.
|
73
74
|
|
74
|
-
deploy
|
75
|
-
Runs every recipe script on the servers declared in layout.json
|
76
|
-
|
75
|
+
deploy environment
|
76
|
+
Runs every recipe script on the servers declared in layout.json for
|
77
|
+
the given environment.
|
78
|
+
Deploying halts on the first failed recipe.
|
77
79
|
|
78
|
-
exec
|
79
|
-
Runs an arbitrary command on the
|
80
|
+
exec environment command
|
81
|
+
Runs an arbitrary command on all servers of the given environment.
|
80
82
|
|
81
83
|
USAGE
|
82
84
|
To provision two servers called `server1` and `server2` with Redis,
|
@@ -95,9 +97,11 @@ USAGE
|
|
95
97
|
"db": ["redis"]
|
96
98
|
},
|
97
99
|
|
98
|
-
"
|
99
|
-
"
|
100
|
-
|
100
|
+
"environments": {
|
101
|
+
"development" {
|
102
|
+
"server1": ["db"],
|
103
|
+
"server2": ["db"]
|
104
|
+
}
|
101
105
|
}
|
102
106
|
}
|
103
107
|
|
@@ -110,10 +114,7 @@ USAGE
|
|
110
114
|
Hostname 10.0.0.2
|
111
115
|
|
112
116
|
# Run tele deploy
|
113
|
-
$ tele deploy
|
114
|
-
|
115
|
-
# Run tele deploy only for server1
|
116
|
-
$ tele deploy -s server1
|
117
|
+
$ tele deploy development
|
117
118
|
|
118
119
|
INSTALLATION
|
119
120
|
$ gem install tele
|
data/bin/tele
CHANGED
@@ -11,6 +11,12 @@ require "json"
|
|
11
11
|
|
12
12
|
trap(:INT) { puts; exit 1 }
|
13
13
|
|
14
|
+
def flunk(message)
|
15
|
+
$stderr.puts(message)
|
16
|
+
$stderr.puts("Run `tele -h` if you need help.")
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
14
20
|
def recipes_for(assigned_roles)
|
15
21
|
[].tap do |recipes|
|
16
22
|
assigned_roles.each do |name|
|
@@ -37,8 +43,12 @@ def layout
|
|
37
43
|
$layout ||= JSON.parse(File.read(path("layout.json")))
|
38
44
|
end
|
39
45
|
|
46
|
+
def environments
|
47
|
+
layout["environments"]
|
48
|
+
end
|
49
|
+
|
40
50
|
def servers
|
41
|
-
$
|
51
|
+
environments[$environment]
|
42
52
|
end
|
43
53
|
|
44
54
|
def roles
|
@@ -120,14 +130,6 @@ commands = Clap.run ARGV,
|
|
120
130
|
},
|
121
131
|
"-d" => lambda { |path|
|
122
132
|
ENV["TELE_HOME"] = File.join(Dir.pwd, path)
|
123
|
-
},
|
124
|
-
"-s" => lambda { |server|
|
125
|
-
unless servers.has_key?(server)
|
126
|
-
$stderr.puts "Unknown server: #{server}"
|
127
|
-
exit 1
|
128
|
-
end
|
129
|
-
|
130
|
-
servers.delete_if { |s, _| s != server }
|
131
133
|
}
|
132
134
|
|
133
135
|
commands = Clap.run commands,
|
@@ -138,12 +140,11 @@ commands = Clap.run commands,
|
|
138
140
|
%x{cp -r #{source} #{target}}
|
139
141
|
|
140
142
|
%x{find #{target} -name .empty -print0 | xargs rm}
|
143
|
+
|
144
|
+
exit 0
|
141
145
|
}
|
142
146
|
|
143
|
-
unless File.directory?(path)
|
144
|
-
$stderr.puts "Couldn't find a .tele directory"
|
145
|
-
exit 1
|
146
|
-
end
|
147
|
+
flunk("Couldn't find a .tele directory.") unless File.directory?(path)
|
147
148
|
|
148
149
|
SSH_OPTIONS = [
|
149
150
|
"-T",
|
@@ -151,6 +152,12 @@ SSH_OPTIONS = [
|
|
151
152
|
"-S", "/tmp/ssh-%r@%h:%p",
|
152
153
|
]
|
153
154
|
|
155
|
+
flunk("Can't find any environments.") unless environments
|
156
|
+
|
157
|
+
$environment = commands.delete_at(1)
|
158
|
+
|
159
|
+
flunk("Unknown environment: #{$environment}") unless environments[$environment]
|
160
|
+
|
154
161
|
commands = Clap.run commands,
|
155
162
|
"exec" => lambda { |cmd|
|
156
163
|
connect do |server, _|
|
@@ -170,7 +177,4 @@ commands = Clap.run commands,
|
|
170
177
|
end
|
171
178
|
}
|
172
179
|
|
173
|
-
unless commands.empty?
|
174
|
-
$stderr.puts "Error: unrecognized parameter: #{commands.join(" ")}"
|
175
|
-
exit 1
|
176
|
-
end
|
180
|
+
flunk("Error: unrecognized parameter: #{commands.join(" ")}") unless commands.empty?
|
data/tele.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.name = "tele"
|
5
5
|
s.version = Tele::VERSION
|
6
6
|
s.summary = "Provisioning at a distance"
|
7
|
-
s.description = "Tele is a small provisioning framework that allows you to run
|
7
|
+
s.description = "Tele is a small provisioning framework that allows you to run shell scripts on remote servers over SSH."
|
8
8
|
s.authors = ["Damian Janowski", "Michel Martens"]
|
9
9
|
s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
|
10
10
|
s.homepage = "http://github.com/djanowski/tele"
|
data/templates/.tele/layout.json
CHANGED
data/test/tele.rb
CHANGED
@@ -28,14 +28,14 @@ test "`tele deploy` fails without a config" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test "`tele deploy` displays missing recipes" do
|
31
|
-
out, err = tele("deploy", "-d", "test/.tele.missing-recipes")
|
31
|
+
out, err = tele("deploy", "-d", "test/.tele.missing-recipes", "production")
|
32
32
|
|
33
33
|
assert out =~ /db-1/
|
34
34
|
assert out =~ /redis.*: .*\?/
|
35
35
|
end
|
36
36
|
|
37
37
|
test "`tele deploy` displays layout" do
|
38
|
-
out, err = tele("deploy", "-d", "test/.tele")
|
38
|
+
out, err = tele("deploy", "-d", "test/.tele", "production")
|
39
39
|
|
40
40
|
assert err.empty?
|
41
41
|
|
@@ -53,32 +53,30 @@ test "`tele deploy` displays layout" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
test "`tele deploy` runs recipes" do
|
56
|
-
out, err = tele("deploy", "-d", "test/.tele.simple")
|
56
|
+
out, err = tele("deploy", "-d", "test/.tele.simple", "production")
|
57
57
|
|
58
|
-
assert out =~ %r[^
|
59
|
-
assert out =~ %r[^
|
60
|
-
assert out =~ %r[^
|
61
|
-
assert out =~ %r[^
|
58
|
+
assert out =~ %r[^app-1/cassandra.* .*Can't find Cassandra]
|
59
|
+
assert out =~ %r[^app-1/cassandra.* .*ERROR]
|
60
|
+
assert out =~ %r[^app-1/redis.* Installed]
|
61
|
+
assert out =~ %r[^app-1/redis.* .*OK]
|
62
62
|
end
|
63
63
|
|
64
|
-
test "`tele deploy
|
65
|
-
out, err = tele(
|
64
|
+
test "`tele deploy ENVIRONMENT` only deploys the given environment" do
|
65
|
+
out, err = tele(*%w[deploy -d test/.tele.envs staging])
|
66
66
|
|
67
|
-
assert
|
68
|
-
|
69
|
-
assert out =~ %r[production/cassandra.*: .*ERROR]
|
70
|
-
assert out =~ %r[production/redis.*: .*OK]
|
67
|
+
assert File.exist?("/tmp/tele/staging")
|
68
|
+
assert !File.exist?("/tmp/tele/production")
|
71
69
|
end
|
72
70
|
|
73
71
|
test "`tele deploy` halts deploy if a recipe fails" do
|
74
|
-
out, err = tele("deploy", "-d", "test/.tele.error")
|
72
|
+
out, err = tele("deploy", "-d", "test/.tele.error", "production")
|
75
73
|
|
76
74
|
assert out =~ %r[db-1/cassandra.*: .*ERROR]
|
77
75
|
assert out !~ %r[db-1/no-run]
|
78
76
|
end
|
79
77
|
|
80
78
|
test "`tele deploy` doesn't run the same recipe twice in a single server" do
|
81
|
-
out, err = tele("deploy", "-d", "test/.tele.simple")
|
79
|
+
out, err = tele("deploy", "-d", "test/.tele.simple", "production")
|
82
80
|
|
83
81
|
assert_equal File.read("/tmp/tele/touch-count").to_i, 1
|
84
82
|
end
|
@@ -98,19 +96,19 @@ test "`tele init`" do
|
|
98
96
|
assert File.exists?(".tele/recipes")
|
99
97
|
assert !File.exists?(".tele/recipes/.empty")
|
100
98
|
|
101
|
-
out, err, status = tele("deploy")
|
99
|
+
out, err, status = tele("deploy", "production")
|
102
100
|
assert status.exitstatus == 0
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
104
|
test "`tele foobar` shouts an error" do
|
107
|
-
out, err = tele("foobar", "-d", "test/.tele.simple")
|
105
|
+
out, err = tele("foobar", "-d", "test/.tele.simple", "production")
|
108
106
|
|
109
107
|
assert err.include?("Error: unrecognized parameter: foobar")
|
110
108
|
end
|
111
109
|
|
112
110
|
test "`tele exec` runs commands" do
|
113
|
-
out, err = tele("exec", "echo foo", "-d", "test/.tele.simple")
|
111
|
+
out, err = tele("exec", "production", "echo foo", "-d", "test/.tele.simple")
|
114
112
|
|
115
|
-
assert out.include?("
|
113
|
+
assert out.include?("app-1: foo")
|
116
114
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: clap
|
17
|
-
requirement: &
|
17
|
+
requirement: &70324407389760 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,8 +22,8 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
description: Tele is a small provisioning framework that allows you to run
|
25
|
+
version_requirements: *70324407389760
|
26
|
+
description: Tele is a small provisioning framework that allows you to run shell scripts
|
27
27
|
on remote servers over SSH.
|
28
28
|
email:
|
29
29
|
- djanowski@dimaion.com
|