blackstack-deployer 1.2.15 → 1.2.16
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.
- checksums.yaml +4 -4
- data/lib/blackstack-deployer.rb +53 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7466aeed2f2ea365d7db6a32c0ce631f003250d0be94c57a7622ed25ae7089b
|
4
|
+
data.tar.gz: 95ec5407f0e0a90b48fa586c51d9c4e22b35cd54343d6d937ce5377f12f6c657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b803e9242d6b063f3a77b4185e027bb6e242bf7ec1ea711b7c6ed838a3420688f53a8074ea6e8ac8d11dc1c645c566ec434c2c4b748b471014e68783a86e3f6
|
7
|
+
data.tar.gz: c1435b21e31e84d11b1bb9d193672423706a0342bfb6434fa1f64689eb89a8d33f5d40ce6f42313c19cff736082c4a03f49d76414116a8b14ad7ff06f647ee51
|
data/lib/blackstack-deployer.rb
CHANGED
@@ -5,14 +5,25 @@ module BlackStack
|
|
5
5
|
# Deployer is a library that can be used to deploy a cluster of nodes.
|
6
6
|
module Deployer
|
7
7
|
@@logger = BlackStack::BaseLogger.new(nil)
|
8
|
+
@@show_output = false
|
8
9
|
@@nodes = []
|
9
10
|
@@routines = []
|
10
11
|
|
12
|
+
# set show_output
|
13
|
+
def self.set_show_output(value)
|
14
|
+
@@show_output = value
|
15
|
+
end
|
16
|
+
|
11
17
|
# set the logger
|
12
18
|
def self.set_logger(i_logger)
|
13
19
|
@@logger = i_logger
|
14
20
|
end
|
15
21
|
|
22
|
+
# get show_output
|
23
|
+
def self.show_output
|
24
|
+
@@show_output
|
25
|
+
end
|
26
|
+
|
16
27
|
# get the logger assigned to the module
|
17
28
|
def self.logger
|
18
29
|
@@logger
|
@@ -165,8 +176,8 @@ module BlackStack
|
|
165
176
|
if h[:errors].size == 0
|
166
177
|
#BlackStack::Deployer.logger.done
|
167
178
|
else
|
168
|
-
BlackStack::Deployer.logger.logf('error: ' + h.to_s)
|
169
|
-
raise "Error running command
|
179
|
+
#BlackStack::Deployer.logger.logf('error: ' + h.to_s)
|
180
|
+
raise "Error running command:\n#{h[:errors].uniq.join("\n")}"
|
170
181
|
end
|
171
182
|
end
|
172
183
|
ret
|
@@ -175,7 +186,7 @@ module BlackStack
|
|
175
186
|
|
176
187
|
# define attributes and methods of a routine's command
|
177
188
|
module CommandModule
|
178
|
-
attr_accessor :command, :matches, :nomatches, :sudo
|
189
|
+
attr_accessor :command, :matches, :nomatches, :sudo, :background
|
179
190
|
|
180
191
|
def self.descriptor_errors(c)
|
181
192
|
errors = []
|
@@ -229,6 +240,12 @@ module BlackStack
|
|
229
240
|
end # each
|
230
241
|
end # if c[:matches].is_a?(Array)
|
231
242
|
end # if :matches exists
|
243
|
+
|
244
|
+
# if c[:background] exists, it must be a boolean
|
245
|
+
if c.has_key?(:background)
|
246
|
+
errors << "The value of the key :background is not a boolean" unless c[:background].is_a?(TrueClass) || c[:background].is_a?(FalseClass)
|
247
|
+
end
|
248
|
+
|
232
249
|
#
|
233
250
|
errors.uniq
|
234
251
|
end # def self.descriptor_error(h)
|
@@ -257,7 +274,12 @@ module BlackStack
|
|
257
274
|
self.nomatches << BlackStack::Deployer::NoMatch.new(m)
|
258
275
|
end
|
259
276
|
end
|
260
|
-
end
|
277
|
+
end
|
278
|
+
if h.has_key?(:background)
|
279
|
+
self.background = h[:background]
|
280
|
+
else
|
281
|
+
self.background = false
|
282
|
+
end
|
261
283
|
end # def initialize(h)
|
262
284
|
|
263
285
|
def to_hash
|
@@ -276,6 +298,7 @@ module BlackStack
|
|
276
298
|
end # def to_hash
|
277
299
|
|
278
300
|
def run(node)
|
301
|
+
l = BlackStack::Deployer.logger
|
279
302
|
errors = []
|
280
303
|
code = self.command
|
281
304
|
output = nil
|
@@ -316,8 +339,28 @@ module BlackStack
|
|
316
339
|
end
|
317
340
|
end
|
318
341
|
|
342
|
+
# if the command is configured to run in background, and the flag show_ouput is off, then modify the code to run in background
|
343
|
+
if self.background && !BlackStack::Deployer.show_output
|
344
|
+
lines = code.strip.lines
|
345
|
+
total = lines.size
|
346
|
+
i = 0
|
347
|
+
lines.each { |l|
|
348
|
+
i += 1
|
349
|
+
if i == total
|
350
|
+
l.gsub!(/;$/, '> /dev/null 2>&1 &')
|
351
|
+
else
|
352
|
+
l.gsub!(/;$/, '> /dev/null 2>&1;')
|
353
|
+
end
|
354
|
+
}
|
355
|
+
code = lines.join("\n")
|
356
|
+
end
|
357
|
+
|
319
358
|
# running the command
|
359
|
+
l.logs "Show command output... " if BlackStack::Deployer.show_output
|
360
|
+
l.log "\n\nCommand:\n--------\n\n#{code} " if BlackStack::Deployer.show_output
|
320
361
|
output = node.exec(code, self.sudo)
|
362
|
+
l.log "\n\nOutput:\n-------\n\n#{output}" if BlackStack::Deployer.show_output
|
363
|
+
l.logf('done tracing.') if BlackStack::Deployer.show_output
|
321
364
|
|
322
365
|
# validation: at least one of the matches should happen
|
323
366
|
if self.matches.size > 0
|
@@ -514,19 +557,19 @@ module BlackStack
|
|
514
557
|
raise "The routine #{routine_name} cannot be run on the node #{node_name}: #{errors.uniq.join(".\n")}" if errors.length > 0
|
515
558
|
|
516
559
|
# connect the node
|
517
|
-
self.logger.logs "Connecting to node #{n.name}... "
|
560
|
+
#self.logger.logs "Connecting to node #{n.name}... "
|
518
561
|
n.connect
|
519
|
-
self.logger.done
|
562
|
+
#self.logger.done
|
520
563
|
|
521
564
|
# run the routine
|
522
|
-
self.logger.logs "Running routine #{r.name}... "
|
565
|
+
#self.logger.logs "Running routine #{r.name}... "
|
523
566
|
r.run(n)
|
524
|
-
self.logger.done
|
567
|
+
#self.logger.done
|
525
568
|
|
526
569
|
# disconnect the node
|
527
|
-
self.logger.logs "Disconnecting from node #{n.name}... "
|
570
|
+
#self.logger.logs "Disconnecting from node #{n.name}... "
|
528
571
|
n.disconnect
|
529
|
-
self.logger.done
|
572
|
+
#self.logger.done
|
530
573
|
|
531
574
|
end # def
|
532
575
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blackstack-nodes
|