tele 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +4 -4
  2. data/bin/tele +49 -35
  3. data/tele.gemspec +1 -1
  4. data/test/tele.rb +6 -0
  5. metadata +3 -3
data/README CHANGED
@@ -6,7 +6,7 @@ NAME
6
6
  SYNOPSIS
7
7
  tele init
8
8
  tele deploy [-d path] [-s server]
9
- tele tail
9
+ tele exec [-d path] [-s server] command
10
10
  tele -h
11
11
 
12
12
  DESCRIPTION
@@ -75,8 +75,8 @@ DESCRIPTION
75
75
  Runs every recipe script on the servers declared in layout.json. The
76
76
  exit code must be 0 if the command was successful.
77
77
 
78
- tail
79
- Displays standard output and standard error from each running recipe.
78
+ exec
79
+ Runs an arbitrary command on the matching servers.
80
80
 
81
81
  USAGE
82
82
  To provision two servers called `server1` and `server2` with Redis,
@@ -116,4 +116,4 @@ USAGE
116
116
  $ tele deploy -s server1
117
117
 
118
118
  INSTALLATION
119
- $ gem install tele
119
+ $ gem install tele
data/bin/tele CHANGED
@@ -45,26 +45,54 @@ def roles
45
45
  layout["roles"]
46
46
  end
47
47
 
48
- def run(server, recipe)
49
- script = path("recipes", "#{recipe}.sh")
48
+ def run(server, recipe, script)
49
+ $out.server(server, recipe)
50
50
 
51
- if File.exist?(script)
52
- IO.popen(ssh(server, SSH_OPTIONS), "r+") do |io|
53
- io.puts(File.read(script))
54
- io.close_write
51
+ if script.nil?
52
+ $out.unknown
53
+ print "\n"
54
+ return
55
+ end
55
56
 
56
- while line = io.gets
57
- yield(line)
58
- end
57
+ result = execute(server, script) do |line|
58
+ print line
59
+ $out.server(server, recipe)
60
+ end
61
+
62
+ case result
63
+ when 0
64
+ $out.ok
65
+ else
66
+ $out.error
67
+ end
68
+
69
+ print "\n"
70
+ end
71
+
72
+ def execute(server, script)
73
+ IO.popen(ssh(server, SSH_OPTIONS), "r+") do |io|
74
+ io.puts(script)
75
+ io.close_write
76
+
77
+ while line = io.gets
78
+ yield(line)
59
79
  end
80
+ end
60
81
 
61
- $?.exitstatus
82
+ $?.exitstatus
83
+ end
84
+
85
+ def connect(&block)
86
+ servers.each do |server, _|
87
+ IO.popen(ssh(server, SSH_OPTIONS + %w[-Mq]), "w")
62
88
  end
89
+
90
+ servers.each(&block)
63
91
  end
64
92
 
65
- out = Module.new do
66
- def self.recipe(server, recipe)
67
- print "#{server}/#{recipe}: "
93
+ $out = Module.new do
94
+ def self.server(server, recipe)
95
+ print "#{[server, recipe].compact.join("/")}: "
68
96
  end
69
97
 
70
98
  def self.error
@@ -122,32 +150,18 @@ SSH_OPTIONS = [
122
150
  ]
123
151
 
124
152
  commands = Clap.run commands,
125
- "deploy" => lambda {
126
- servers.each do |server, _|
127
- IO.popen(ssh(server, SSH_OPTIONS + %w[-Mq]), "w")
153
+ "exec" => lambda { |cmd|
154
+ connect do |server, _|
155
+ run(server, nil, cmd)
128
156
  end
157
+ },
129
158
 
130
- servers.each do |server, assigned_roles|
159
+ "deploy" => lambda {
160
+ connect do |server, assigned_roles|
131
161
  recipes_for(assigned_roles).each do |recipe|
132
- out.recipe(server, recipe)
133
-
134
- # first = true
135
-
136
- result = run(server, recipe) do |line|
137
- print line
138
- out.recipe(server, recipe) # unless first
139
- end
140
-
141
- case result
142
- when nil
143
- out.unknown
144
- when 0
145
- out.ok
146
- else
147
- out.error
148
- end
162
+ script = path("recipes", "#{recipe}.sh")
149
163
 
150
- print "\n"
164
+ run(server, recipe, (File.read(script) if File.exist?(script)))
151
165
  end
152
166
  end
153
167
  }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "tele"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
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"]
@@ -101,3 +101,9 @@ test "`tele foobar` shouts an error" do
101
101
 
102
102
  assert err.include?("Error: unrecognized parameter: foobar")
103
103
  end
104
+
105
+ test "`tele exec` runs commands" do
106
+ out, err = tele("exec", "echo foo", "-d", "test/.tele.simple")
107
+
108
+ assert out.include?("staging: foo")
109
+ 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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: clap
17
- requirement: &70301175305080 !ruby/object:Gem::Requirement
17
+ requirement: &70350700960560 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70301175305080
25
+ version_requirements: *70350700960560
26
26
  description: Tele is a small provisioning framework that allows you to run bash scripts
27
27
  on remote servers over SSH.
28
28
  email: