my-ruby-deployer 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/my-ruby-deployer.rb +17 -12
- metadata +2 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0330fe5840899f6a649f4e5e9ce04039ba883b599d76de530fafea9f703a80
|
4
|
+
data.tar.gz: 4ac3a19b11c83ffefe2f266b991eff09b1e46a3a349a2e46e6bf65360cd9bac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a6d27889df5a4b81fefc6ef188f21aba08147e903bee5da21fa50ae746bf59af275a932b8b0a63e6763d9640c3a1545680dc8c3214c014dbb764a703059544f
|
7
|
+
data.tar.gz: 3f553255065000e8cd4aaed5b9cdb1d85698ab5dd634f13dd39eb3283c802516b96488e24c44641b25ecd45dad55b1ac591b429dd0642542edd4c404df914882
|
data/lib/my-ruby-deployer.rb
CHANGED
@@ -147,14 +147,14 @@ module BlackStack
|
|
147
147
|
h
|
148
148
|
end
|
149
149
|
|
150
|
-
def run(node, l=nil)
|
150
|
+
def run(node, l=nil, params={})
|
151
151
|
l = BlackStack::DummyLogger.new(nil) if l.nil?
|
152
152
|
l.logs "Running routine #{self.name.blue} on node #{node.name.blue}... "
|
153
153
|
i = 0
|
154
154
|
self.commands.each do |c|
|
155
155
|
i += 1
|
156
156
|
l.logs "Command #{i.to_s.blue}... "
|
157
|
-
c.run(node, l)
|
157
|
+
c.run(node, l, params)
|
158
158
|
l.logf 'done'.green
|
159
159
|
end
|
160
160
|
l.logf 'done'.green
|
@@ -210,7 +210,7 @@ module BlackStack
|
|
210
210
|
# running pre-defined commands: :root
|
211
211
|
# calling to other routines: :'change-name'
|
212
212
|
# calling
|
213
|
-
def run(n, l=nil)
|
213
|
+
def run(n, l=nil, params={})
|
214
214
|
l = BlackStack::DummyLogger.new(nil) if l.nil?
|
215
215
|
|
216
216
|
# if self.command is a symbol
|
@@ -224,7 +224,7 @@ module BlackStack
|
|
224
224
|
# look for a routine with this name
|
225
225
|
r = BlackStack::Deployer.routines.select { |r| r.name == self.command.to_s }.first
|
226
226
|
if !r.nil?
|
227
|
-
r.run(n)
|
227
|
+
r.run(n, l, params)
|
228
228
|
else
|
229
229
|
raise "The routine #{self.command.to_s} does not exist"
|
230
230
|
end
|
@@ -234,22 +234,26 @@ module BlackStack
|
|
234
234
|
elsif self.command.is_a?(String)
|
235
235
|
s = self.command.dup
|
236
236
|
|
237
|
-
l.logs "Replacing merge-tags... "
|
237
|
+
#l.logs "Replacing merge-tags... "
|
238
238
|
s.scan(/%[a-zA-Z0-9\_]+%/).uniq.each do |p|
|
239
|
-
l.logs "Replacing #{p.blue}... "
|
239
|
+
#l.logs "Replacing #{p.blue}... "
|
240
240
|
if p == '%timestamp%' # reserved parameter
|
241
241
|
# TODO: move this to a timestamp function on blackstack-core
|
242
242
|
s.gsub!(p, Time.now.to_s.gsub(/\D/, ''))
|
243
243
|
else
|
244
|
+
# replace node parameters
|
244
245
|
if n.parameters.has_key?(p.gsub(/%/, '').to_sym)
|
245
246
|
s.gsub!(p, n.parameters[p.gsub(/%/, '').to_sym].to_s)
|
247
|
+
# replace routine-call parameters
|
248
|
+
elsif params.has_key?(p.gsub(/%/, '').to_sym)
|
249
|
+
s.gsub!(p, params[p.gsub(/%/, '').to_sym].to_s)
|
246
250
|
else
|
247
251
|
raise "The parameter #{p} does not exist in the node descriptor #{n.parameters.to_s}"
|
248
252
|
end
|
249
253
|
end
|
250
|
-
l.logf 'done'.green
|
254
|
+
#l.logf 'done'.green
|
251
255
|
end
|
252
|
-
l.logf 'done'.green
|
256
|
+
#l.logf 'done'.green
|
253
257
|
|
254
258
|
l.logs "Running command... "
|
255
259
|
n.ssh.exec!(s)
|
@@ -318,7 +322,7 @@ module BlackStack
|
|
318
322
|
end # def
|
319
323
|
|
320
324
|
# running a routine on a node
|
321
|
-
def self.run_routine(node_name, routine_name, l=nil)
|
325
|
+
def self.run_routine(node_name, routine_name, l=nil, params={})
|
322
326
|
l = BlackStack::DummyLogger.new(nil) if l.nil?
|
323
327
|
errors = []
|
324
328
|
|
@@ -344,7 +348,7 @@ module BlackStack
|
|
344
348
|
|
345
349
|
# run the routine
|
346
350
|
l.logs "Running routine #{r.name}... "
|
347
|
-
r.run(n, l)
|
351
|
+
r.run(n, l, params)
|
348
352
|
l.done
|
349
353
|
|
350
354
|
# disconnect the node
|
@@ -354,7 +358,7 @@ module BlackStack
|
|
354
358
|
end # def self.run_routine
|
355
359
|
|
356
360
|
module DB
|
357
|
-
LOCKFILE = './
|
361
|
+
LOCKFILE = './my-ruby-deployer.lock'
|
358
362
|
@@checkpoint = nil
|
359
363
|
@@superhuser = nil
|
360
364
|
@@ndb = nil
|
@@ -418,7 +422,7 @@ module BlackStack
|
|
418
422
|
# This method should not be called directly by user code.
|
419
423
|
def self.execute_sentences(sql, chunk_size=200, l=nil)
|
420
424
|
l = BlackStack::DummyLogger.new(nil) if l.nil?
|
421
|
-
|
425
|
+
|
422
426
|
# Fix issue: Ruby `split': invalid byte sequence in UTF-8 (ArgumentError)
|
423
427
|
# Reference: https://stackoverflow.com/questions/11065962/ruby-split-invalid-byte-sequence-in-utf-8-argumenterror
|
424
428
|
#
|
@@ -462,6 +466,7 @@ module BlackStack
|
|
462
466
|
def self.deploy(save_checkpoints=false, lockfilename=BlackStack::Deployer::DB::LOCKFILE, l=nil)
|
463
467
|
l = BlackStack::DummyLogger.new(nil) if l.nil?
|
464
468
|
# get list of `.sql` files in the directory `sql_path`, with a name higher than `last_filename`, sorted by name.
|
469
|
+
|
465
470
|
Dir.entries(@@folder).select {
|
466
471
|
|filename| filename =~ /\.sql$/ && filename > @@checkpoint.to_s
|
467
472
|
}.uniq.sort.each { |filename|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my-ruby-deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
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:
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blackstack-nodes
|
@@ -70,46 +70,6 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 5.56.0
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: websocket
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 1.2.8
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.2.8
|
83
|
-
type: :runtime
|
84
|
-
prerelease: false
|
85
|
-
version_requirements: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.2.8
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 1.2.8
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
name: json
|
95
|
-
requirement: !ruby/object:Gem::Requirement
|
96
|
-
requirements:
|
97
|
-
- - "~>"
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: 2.3.0
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 2.3.0
|
103
|
-
type: :runtime
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 2.3.0
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 2.3.0
|
113
73
|
- !ruby/object:Gem::Dependency
|
114
74
|
name: colorize
|
115
75
|
requirement: !ruby/object:Gem::Requirement
|