nomadsl 0.1.2 → 0.2.1
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 +5 -5
- data/README.md +21 -5
- data/bin/nomadsl +5 -0
- data/lib/nomadsl.rb +276 -61
- data/lib/nomadsl/version.rb +1 -1
- data/nomadsl.gemspec +4 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e373810efb5dc4ba6cb71d0788e6e114c6bb9db7f5eacd7aa45e5a3d5cf8903
|
4
|
+
data.tar.gz: 94270c72e2bf26c7c387c87ae9d612dbb5ce2de26decadec9559cd963d1440c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f1d263ba2e882a691724734df548cd91fd948bbd15d6ed2a51d8b5a7a376548dd1e6faaab24067d4defb5f713f40731cf83d459193637a5f1d14a2bf845522d
|
7
|
+
data.tar.gz: 752afd8496be3adfbe72c38dc7890c85e3f724f64ab5515a59e41bbfb9f580cf7659a377241b03f72a6b41cd79781bf4d09a28bc1b1fbb73b91c7dfe5acd5ed7
|
data/README.md
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
Nomadsl is a Ruby DSL for generating Nomad job specification files.
|
4
4
|
|
5
|
-
Methods mapping to keys and attributes described in the
|
6
|
-
(https://www.nomadproject.io/docs/job-specification/index.html)
|
7
|
-
an includable module.
|
5
|
+
Methods mapping to keys and attributes described in the
|
6
|
+
[Nomad Job Specification](https://www.nomadproject.io/docs/job-specification/index.html)
|
7
|
+
are defined in an includable module.
|
8
8
|
|
9
|
-
|
9
|
+
Nomadsl supports Nomad configuration syntax through version 0.12.0. The mapping
|
10
|
+
of key and attribute names to method names is generally one-to-one, but you can
|
11
|
+
specify arbitrary configuration values to be rendered if necessary.
|
10
12
|
|
11
13
|
## Example: DSL direct to stdout
|
12
14
|
|
@@ -85,6 +87,21 @@ Will generate this output:
|
|
85
87
|
}
|
86
88
|
}
|
87
89
|
|
90
|
+
## Using `nomadsl` as the interpreter
|
91
|
+
|
92
|
+
You can also set your shbang line to use `nomadsl` as the interpreter of the
|
93
|
+
script. This will evaluate everything as Ruby, but with the necessary `nomadsl`
|
94
|
+
boilerplate already built in:
|
95
|
+
|
96
|
+
#!/usr/bin/env nomadsl
|
97
|
+
|
98
|
+
job "nomadsl-example" do
|
99
|
+
# ...
|
100
|
+
end
|
101
|
+
|
102
|
+
If the file is then marked as executable, you can simply run it to generate
|
103
|
+
the corresponding Nomad job specification.
|
104
|
+
|
88
105
|
## Other uses
|
89
106
|
|
90
107
|
By requiring only `nomadsl`, you can inject these methods into another class:
|
@@ -107,7 +124,6 @@ By requiring only `nomadsl`, you can inject these methods into another class:
|
|
107
124
|
|
108
125
|
## Roadmap
|
109
126
|
|
110
|
-
* Make all attributes explicitly callable
|
111
127
|
* Make subkeys embeddable in arglists if sensible
|
112
128
|
* Allow injecting comments into the rendered file
|
113
129
|
* Finish custom config blocks for each task driver
|
data/bin/nomadsl
ADDED
data/lib/nomadsl.rb
CHANGED
@@ -13,6 +13,10 @@ module Nomadsl
|
|
13
13
|
@nomadsl_print = b
|
14
14
|
end
|
15
15
|
|
16
|
+
def parent
|
17
|
+
@stack.last
|
18
|
+
end
|
19
|
+
|
16
20
|
def only(*levels)
|
17
21
|
unless levels.include? @stack.last
|
18
22
|
loc = caller_locations(1,1)[0]
|
@@ -69,6 +73,21 @@ module Nomadsl
|
|
69
73
|
@out << "#{v.chomp}\nBLOB\n"
|
70
74
|
end
|
71
75
|
|
76
|
+
def strmap!(k, v)
|
77
|
+
die "Value for '#{k}' is nil" if v.nil?
|
78
|
+
strmap(k, v)
|
79
|
+
end
|
80
|
+
|
81
|
+
def strmap(k, v)
|
82
|
+
if v
|
83
|
+
block(k) do
|
84
|
+
v.each do |k2,v2|
|
85
|
+
str k2, v2
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
72
91
|
# try really hard
|
73
92
|
def any(k, v)
|
74
93
|
if v.nil?
|
@@ -137,18 +156,23 @@ module Nomadsl
|
|
137
156
|
str! :source, source
|
138
157
|
str :destination, destination
|
139
158
|
str :mode, mode
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
159
|
+
strmap :options, options
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# https://www.nomadproject.io/docs/job-specification/affinity.html
|
164
|
+
def affinity(attribute: nil, operator: nil, value: nil, weight: nil)
|
165
|
+
only :job, :group, :task, :device
|
166
|
+
block(:affinity) do
|
167
|
+
str! :attribute, attribute
|
168
|
+
str :operator, operator
|
169
|
+
str! :value, value
|
170
|
+
int :weight, weight
|
147
171
|
end
|
148
172
|
end
|
149
173
|
|
150
174
|
# https://www.nomadproject.io/docs/job-specification/service.html#check-parameters
|
151
|
-
def check(address_mode: nil, args: nil, command: nil, grpc_service: nil, grpc_use_tls: nil, initial_status: nil, interval: nil, method: nil, name: nil, path: nil, port: nil, protocol: nil, timeout: nil, type: nil, tls_skip_verify: nil)
|
175
|
+
def check(address_mode: nil, args: nil, command: nil, grpc_service: nil, grpc_use_tls: nil, initial_status: nil, interval: nil, method: nil, name: nil, path: nil, expose: nil, port: nil, protocol: nil, task: nil, timeout: nil, type: nil, tls_skip_verify: nil)
|
152
176
|
only :service
|
153
177
|
block(:check) do
|
154
178
|
str :address_mode, address_mode
|
@@ -157,14 +181,16 @@ module Nomadsl
|
|
157
181
|
str :grpc_service, grpc_service
|
158
182
|
bool :grpc_use_tls, grpc_use_tls
|
159
183
|
str :initial_status, initial_status
|
160
|
-
str :interval, interval
|
184
|
+
str! :interval, interval
|
161
185
|
str :method, method
|
162
186
|
str :name, name
|
163
187
|
str :path, path
|
188
|
+
bool :expose, expose
|
164
189
|
str :port, port
|
165
190
|
str :protocol, protocol
|
166
|
-
str :
|
167
|
-
str :
|
191
|
+
str :task, task
|
192
|
+
str! :timeout, timeout
|
193
|
+
str! :type, type
|
168
194
|
bool :tls_skip_verify, tls_skip_verify
|
169
195
|
yield if block_given?
|
170
196
|
end
|
@@ -182,7 +208,7 @@ module Nomadsl
|
|
182
208
|
|
183
209
|
# https://www.nomadproject.io/docs/job-specification/task.html#config
|
184
210
|
def config(**opts)
|
185
|
-
only :task
|
211
|
+
only :task, :sidecar_task, :proxy
|
186
212
|
config_method = "__config_#{@driver}".to_sym
|
187
213
|
if private_methods.include?(config_method)
|
188
214
|
send(config_method, **opts)
|
@@ -204,10 +230,18 @@ module Nomadsl
|
|
204
230
|
end
|
205
231
|
end
|
206
232
|
|
233
|
+
# https://www.nomadproject.io/docs/job-specification/connect
|
234
|
+
def connect(native: nil)
|
235
|
+
only :service
|
236
|
+
block(:connect) do
|
237
|
+
bool :native, native
|
238
|
+
yield if block_given?
|
239
|
+
end
|
240
|
+
end
|
207
241
|
|
208
242
|
# https://www.nomadproject.io/docs/job-specification/constraint.html
|
209
243
|
def constraint(attribute: nil, operator: nil, value: nil)
|
210
|
-
only :job, :group, :task
|
244
|
+
only :job, :group, :task, :device
|
211
245
|
block(:constraint) do
|
212
246
|
str :attribute, attribute
|
213
247
|
str :operator, operator
|
@@ -215,12 +249,31 @@ module Nomadsl
|
|
215
249
|
end
|
216
250
|
end
|
217
251
|
|
252
|
+
# https://www.nomadproject.io/docs/job-specification/csi_plugin
|
253
|
+
def csi_plugin(id: nil, type: nil, mount_dir: nil)
|
254
|
+
only :volume
|
255
|
+
block(:csi_plugin) do
|
256
|
+
str! :id, id
|
257
|
+
str! :type, type
|
258
|
+
str! :mount_dir, mount_dir
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
218
262
|
# https://www.nomadproject.io/docs/job-specification/job.html#datacenters
|
219
263
|
def datacenters(*d)
|
220
264
|
only :job
|
221
265
|
list! :datacenters, d
|
222
266
|
end
|
223
267
|
|
268
|
+
# https://www.nomadproject.io/docs/job-specification/device.html
|
269
|
+
def device(name: nil, count: nil)
|
270
|
+
only :resources
|
271
|
+
block(:device, name) do
|
272
|
+
int :count, count
|
273
|
+
yield if block_given?
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
224
277
|
# https://www.nomadproject.io/docs/job-specification/dispatch_payload.html
|
225
278
|
def dispatch_payload(file:)
|
226
279
|
only :task
|
@@ -229,14 +282,20 @@ module Nomadsl
|
|
229
282
|
end
|
230
283
|
end
|
231
284
|
|
285
|
+
# https://www.nomadproject.io/docs/job-specification/network#dns-parameters
|
286
|
+
def dns(servers: nil, searches: nil, options: nil)
|
287
|
+
only :network
|
288
|
+
block(:dns) do
|
289
|
+
list :servers, servers
|
290
|
+
list :searches, searches
|
291
|
+
list :options, options
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
232
295
|
# https://www.nomadproject.io/docs/job-specification/env.html
|
233
296
|
def env(**opts)
|
234
|
-
only :task
|
235
|
-
|
236
|
-
opts.each do |k,v|
|
237
|
-
str k, v
|
238
|
-
end
|
239
|
-
end
|
297
|
+
only :task, :sidecar_task
|
298
|
+
strmap :env, opts
|
240
299
|
end
|
241
300
|
|
242
301
|
# https://www.nomadproject.io/docs/job-specification/ephemeral_disk.html
|
@@ -249,11 +308,21 @@ module Nomadsl
|
|
249
308
|
end
|
250
309
|
end
|
251
310
|
|
311
|
+
# https://www.nomadproject.io/docs/job-specification/expose
|
312
|
+
def expose
|
313
|
+
only :proxy
|
314
|
+
block(:expose) do
|
315
|
+
yield if block_given?
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
252
319
|
# https://www.nomadproject.io/docs/job-specification/group.html
|
253
|
-
def group(name, count: nil)
|
320
|
+
def group(name, count: nil, shutdown_delay: nil, stop_after_client_disconnect: nil)
|
254
321
|
only :job
|
255
322
|
block(:group, name) do
|
256
323
|
int :count, count
|
324
|
+
str :shutdown_delay, shutdown_delay
|
325
|
+
str :stop_after_client_disconnect, stop_after_client_disconnect
|
257
326
|
yield
|
258
327
|
end
|
259
328
|
end
|
@@ -266,6 +335,15 @@ module Nomadsl
|
|
266
335
|
end
|
267
336
|
end
|
268
337
|
|
338
|
+
# https://www.nomadproject.io/docs/job-specification/lifecycle
|
339
|
+
def lifecycle(hook: nil, sidecar: nil)
|
340
|
+
only :task
|
341
|
+
block(:lifecycle) do
|
342
|
+
str :hook, hook
|
343
|
+
bool :sidecar, sidecar
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
269
347
|
# https://www.nomadproject.io/docs/job-specification/job.html
|
270
348
|
def job(j)
|
271
349
|
# initialize the variables since this is the actual root
|
@@ -284,7 +362,7 @@ module Nomadsl
|
|
284
362
|
|
285
363
|
# https://www.nomadproject.io/docs/job-specification/logs.html
|
286
364
|
def logs(max_files: nil, max_file_size: nil)
|
287
|
-
only :task
|
365
|
+
only :task, :sidecar_task
|
288
366
|
block(:logs) do
|
289
367
|
int :max_files, max_files
|
290
368
|
int :max_file_size, max_file_size
|
@@ -293,12 +371,8 @@ module Nomadsl
|
|
293
371
|
|
294
372
|
# https://www.nomadproject.io/docs/job-specification/meta.html
|
295
373
|
def meta(**opts)
|
296
|
-
only :job, :group, :task
|
297
|
-
|
298
|
-
opts.each do |k,v|
|
299
|
-
str k, v
|
300
|
-
end
|
301
|
-
end
|
374
|
+
only :job, :group, :task, :sidecar_task, :region
|
375
|
+
strmap :meta, opts
|
302
376
|
end
|
303
377
|
|
304
378
|
# https://www.nomadproject.io/docs/job-specification/migrate.html
|
@@ -312,6 +386,14 @@ module Nomadsl
|
|
312
386
|
end
|
313
387
|
end
|
314
388
|
|
389
|
+
# https://www.nomadproject.io/docs/job-specification/multiregion
|
390
|
+
def multiregion
|
391
|
+
only :job
|
392
|
+
block(:multiregion) do
|
393
|
+
yield if block_given?
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
315
397
|
# https://www.nomadproject.io/docs/job-specification/job.html#namespace
|
316
398
|
# Supported by Nomad Enterprise ONLY
|
317
399
|
def namespace(n)
|
@@ -339,6 +421,17 @@ module Nomadsl
|
|
339
421
|
end
|
340
422
|
end
|
341
423
|
|
424
|
+
# https://www.nomadproject.io/docs/job-specification/expose#path-parameters
|
425
|
+
def path(path: nil, protocol: nil, local_path_port: nil)
|
426
|
+
only :expose
|
427
|
+
block(:path) do
|
428
|
+
str! :path, path
|
429
|
+
str! :protocol, protocol
|
430
|
+
int! :local_path_port, local_path_port
|
431
|
+
yield if block_given?
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
342
435
|
# https://www.nomadproject.io/docs/job-specification/periodic.html
|
343
436
|
def periodic(cron: nil, prohibit_overlap: nil, time_zone: nil)
|
344
437
|
only :job
|
@@ -349,9 +442,15 @@ module Nomadsl
|
|
349
442
|
end
|
350
443
|
end
|
351
444
|
|
445
|
+
# https://www.nomadproject.io/docs/job-specification/scaling#policy
|
446
|
+
def policy(**args)
|
447
|
+
only :scaling
|
448
|
+
any :policy, args
|
449
|
+
end
|
450
|
+
|
352
451
|
# https://www.nomadproject.io/docs/job-specification/network.html#port
|
353
452
|
def port(n, static: nil)
|
354
|
-
only :network
|
453
|
+
only :network, :path
|
355
454
|
if static
|
356
455
|
block(:port, n) do
|
357
456
|
int :static, static
|
@@ -367,10 +466,29 @@ module Nomadsl
|
|
367
466
|
int! :priority, p
|
368
467
|
end
|
369
468
|
|
469
|
+
# https://www.nomadproject.io/docs/job-specification/proxy
|
470
|
+
def proxy(local_service_address: nil, local_service_port: nil)
|
471
|
+
only :sidecar_service
|
472
|
+
block(:proxy) do
|
473
|
+
str :local_service_address, local_service_address
|
474
|
+
int :local_service_port, local_service_port
|
475
|
+
yield if block_given?
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
370
479
|
# https://www.nomadproject.io/docs/job-specification/job.html#region
|
371
|
-
|
372
|
-
|
373
|
-
|
480
|
+
# https://www.nomadproject.io/docs/job-specification/multiregion#region-parameters
|
481
|
+
def region(name, count: nil, datacenters: nil)
|
482
|
+
only :job, :multiregion
|
483
|
+
if parent == :job
|
484
|
+
str! :region, name
|
485
|
+
elsif parent == :multiregion
|
486
|
+
block(:region, name) do
|
487
|
+
int :count, count
|
488
|
+
list :datacenters, datacenters
|
489
|
+
yield if block_given?
|
490
|
+
end
|
491
|
+
end
|
374
492
|
end
|
375
493
|
|
376
494
|
# https://www.nomadproject.io/docs/job-specification/reschedule.html
|
@@ -388,10 +506,9 @@ module Nomadsl
|
|
388
506
|
|
389
507
|
# https://www.nomadproject.io/docs/job-specification/resources.html
|
390
508
|
def resources(cpu: nil, iops: nil, memory: nil)
|
391
|
-
only :task
|
509
|
+
only :task, :sidecar_task
|
392
510
|
block(:resources) do
|
393
511
|
int :cpu, cpu
|
394
|
-
int :iops, iops
|
395
512
|
int :memory, memory
|
396
513
|
yield if block_given?
|
397
514
|
end
|
@@ -408,6 +525,17 @@ module Nomadsl
|
|
408
525
|
end
|
409
526
|
end
|
410
527
|
|
528
|
+
# https://www.nomadproject.io/docs/job-specification/scaling
|
529
|
+
def scaling(min: nil, max: nil, enabled: nil)
|
530
|
+
only :group
|
531
|
+
block(:scaling) do
|
532
|
+
int :min, min
|
533
|
+
int! :max, max
|
534
|
+
bool :enabled, enabled
|
535
|
+
yield if block_given?
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
411
539
|
# https://www.nomadproject.io/docs/job-specification/service.html
|
412
540
|
def service(address_mode: nil, canary_tags: nil, name: nil, port: nil, tags: nil)
|
413
541
|
only :task
|
@@ -421,6 +549,58 @@ module Nomadsl
|
|
421
549
|
end
|
422
550
|
end
|
423
551
|
|
552
|
+
# https://www.nomadproject.io/docs/job-specification/sidecar_service
|
553
|
+
def sidecar_service(tags: nil, port: nil)
|
554
|
+
only :connect
|
555
|
+
block(:sidecar_service) do
|
556
|
+
list :tags, tags
|
557
|
+
int :port, port
|
558
|
+
yield if block_given?
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
# https://www.nomadproject.io/docs/job-specification/sidecar_task
|
563
|
+
def sidecar_task(name: nil, driver: nil, user: nil, logs: nil, kill_timeout: nil, shutdown_delay: nil, kill_signal: nil)
|
564
|
+
only :connect
|
565
|
+
block(:sidecar_task) do
|
566
|
+
str :name, name
|
567
|
+
str :driver, driver
|
568
|
+
str :user, user
|
569
|
+
str :kill_timeout, kill_timeout
|
570
|
+
str :shutdown_delay, shutdown_delay
|
571
|
+
str :kill_signal, kill_signal
|
572
|
+
yielf if block_given?
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
# https://www.nomadproject.io/docs/job-specification/spread.html
|
577
|
+
def spread(attribute: nil, weight: nil)
|
578
|
+
only :job, :group, :task
|
579
|
+
block(:spread) do
|
580
|
+
str! :attribute, attribute
|
581
|
+
int :weight, weight
|
582
|
+
yield if block_given?
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
# https://www.nomadproject.io/docs/job-specification/multiregion#strategy-parameters
|
587
|
+
def strategy(max_parallel: nil, on_failure: nil)
|
588
|
+
only :multiregion
|
589
|
+
block(:strategy) do
|
590
|
+
int :max_parallel, max_parallel
|
591
|
+
str :on_failure, on_failure
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
# https://www.nomadproject.io/docs/job-specification/spread.html#target-parameters
|
596
|
+
def target(name: nil, value: nil, percent: nil)
|
597
|
+
only :spread
|
598
|
+
block(:target, name) do
|
599
|
+
str :value, value
|
600
|
+
str :weight, weight
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
424
604
|
# https://www.nomadproject.io/docs/job-specification/task.html
|
425
605
|
def task(t, driver: "exec", kill_signal: nil, kill_timeout: nil, leader: nil, shutdown_delay: nil, user: nil)
|
426
606
|
only :group
|
@@ -476,6 +656,15 @@ module Nomadsl
|
|
476
656
|
end
|
477
657
|
end
|
478
658
|
|
659
|
+
# https://www.nomadproject.io/docs/job-specification/upstreams
|
660
|
+
def upstreams(destination_name: nil, local_bind_port: nil)
|
661
|
+
only :proxy
|
662
|
+
block(:upstreams) do
|
663
|
+
str! :destination_name, destination_name
|
664
|
+
int! :local_bind_port, local_bind_port
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
479
668
|
# https://www.nomadproject.io/docs/job-specification/vault.html
|
480
669
|
def vault(change_mode: nil, change_token: nil, env: nil, policies: nil)
|
481
670
|
only :job, :group, :task
|
@@ -487,6 +676,26 @@ module Nomadsl
|
|
487
676
|
end
|
488
677
|
end
|
489
678
|
|
679
|
+
# https://www.nomadproject.io/docs/job-specification/volume
|
680
|
+
def volume(name, type: nil, source: nil, read_only: nil)
|
681
|
+
only :group
|
682
|
+
block(:volume, name) do
|
683
|
+
str :type, type
|
684
|
+
str! :source, source
|
685
|
+
bool :read_only, read_only
|
686
|
+
end
|
687
|
+
end
|
688
|
+
|
689
|
+
# https://www.nomadproject.io/docs/job-specification/volume_mount
|
690
|
+
def volume_mount(volume: nil, destination: nil, read_only: nil)
|
691
|
+
only :task
|
692
|
+
block(:volume_mount) do
|
693
|
+
str! :volume, volume
|
694
|
+
str! :destination, destination
|
695
|
+
bool :read_only, read_only
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
490
699
|
# https://www.nomadproject.io/docs/job-specification/job.html#vault_token
|
491
700
|
# NOTE: explicitly unsupported, dangerous
|
492
701
|
|
@@ -502,43 +711,49 @@ module Nomadsl
|
|
502
711
|
end
|
503
712
|
end
|
504
713
|
|
714
|
+
def _vault_aws_creds(path, export)
|
715
|
+
prefix = export ? "export " : ""
|
716
|
+
path = path.is_a?(String) ? [path] : path
|
717
|
+
args = path.reduce("") do |concat, str|
|
718
|
+
concat = "#{concat} \"#{str}\""
|
719
|
+
end
|
720
|
+
<<~DATA
|
721
|
+
{{with secret #{args}}}
|
722
|
+
#{prefix}AWS_ACCESS_KEY_ID={{.Data.access_key}}
|
723
|
+
#{prefix}AWS_SECRET_ACCESS_KEY={{.Data.secret_key}}
|
724
|
+
{{if .Data.security_token}}
|
725
|
+
#{prefix}AWS_SESSION_TOKEN={{.Data.security_token}}
|
726
|
+
{{end}}
|
727
|
+
{{end}}
|
728
|
+
DATA
|
729
|
+
end
|
730
|
+
|
505
731
|
def preloaded_vault_aws_creds(name, path)
|
506
|
-
data
|
507
|
-
{{with secret "#{path}"}}
|
508
|
-
AWS_ACCESS_KEY_ID={{.Data.access_key}}
|
509
|
-
AWS_SECRET_ACCESS_KEY={{.Data.secret_key}}
|
510
|
-
AWS_SESSION_TOKEN={{.Data.security_token}}
|
511
|
-
{{end}}
|
512
|
-
DATA
|
513
|
-
template(data: data, destination: "secrets/#{name}.env", env: true)
|
732
|
+
template(data: _vault_aws_creds(path, false), destination: "secrets/#{name}.env", env: true)
|
514
733
|
end
|
515
734
|
|
516
735
|
def vault_aws_creds(name, path)
|
517
|
-
data
|
518
|
-
|
519
|
-
|
520
|
-
export
|
521
|
-
export
|
522
|
-
|
523
|
-
|
524
|
-
|
736
|
+
template(data: _vault_aws_creds(path, true), destination: "secrets/#{name}.env")
|
737
|
+
end
|
738
|
+
|
739
|
+
def _vault_consul_creds(path, export)
|
740
|
+
prefix = export ? "export " : ""
|
741
|
+
path = path.is_a?(String) ? [path] : path
|
742
|
+
args = path.reduce("") do |concat, str|
|
743
|
+
concat = "#{concat} \"#{str}\""
|
744
|
+
end
|
745
|
+
<<~DATA
|
746
|
+
{{with secret #{args}}}
|
747
|
+
#{prefix}CONSUL_HTTP_TOKEN={{.Data.token}}
|
748
|
+
{{end}}
|
749
|
+
DATA
|
525
750
|
end
|
526
751
|
|
527
752
|
def preloaded_vault_consul_creds(name, path)
|
528
|
-
data
|
529
|
-
{{with secret "#{path}"}}
|
530
|
-
CONSUL_HTTP_TOKEN={{.Data.token}}
|
531
|
-
{{end}}
|
532
|
-
DATA
|
533
|
-
template(data: data, destination: "secrets/#{name}.env", env: true)
|
753
|
+
template(data: _vault_consul_creds(path, false), destination: "secrets/#{name}.env", env: true)
|
534
754
|
end
|
535
755
|
|
536
756
|
def vault_consul_creds(name, path)
|
537
|
-
data
|
538
|
-
{{with secret "#{path}"}}
|
539
|
-
export CONSUL_HTTP_TOKEN={{.Data.token}}
|
540
|
-
{{end}}
|
541
|
-
DATA
|
542
|
-
template(data: data, destination: "secrets/#{name}.env")
|
757
|
+
template(data: _vault_consul_creds(path, true), destination: "secrets/#{name}.env")
|
543
758
|
end
|
544
759
|
end
|
data/lib/nomadsl/version.rb
CHANGED
data/nomadsl.gemspec
CHANGED
@@ -8,14 +8,17 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.date = Time.now.strftime('%Y-%m-%d')
|
9
9
|
s.license = 'CC0'
|
10
10
|
s.homepage = 'https://github.com/daveadams/nomadsl'
|
11
|
-
s.required_ruby_version = '>=2.
|
11
|
+
s.required_ruby_version = '>=2.5.0'
|
12
12
|
|
13
13
|
s.summary = 'Ruby DSL for generating Nomad job specification files'
|
14
14
|
|
15
15
|
s.require_paths = ['lib']
|
16
16
|
s.files = Dir["lib/**/*.rb"] + [
|
17
|
+
'bin/nomadsl',
|
17
18
|
'README.md',
|
18
19
|
'LICENSE',
|
19
20
|
'nomadsl.gemspec'
|
20
21
|
]
|
22
|
+
s.bindir = 'bin'
|
23
|
+
s.executables = ['nomadsl']
|
21
24
|
end
|
metadata
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nomadsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Adams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: daveadams@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- nomadsl
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
19
20
|
- LICENSE
|
20
21
|
- README.md
|
22
|
+
- bin/nomadsl
|
21
23
|
- lib/nomadsl.rb
|
22
24
|
- lib/nomadsl/dsl.rb
|
23
25
|
- lib/nomadsl/version.rb
|
@@ -34,15 +36,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
36
|
requirements:
|
35
37
|
- - ">="
|
36
38
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
39
|
+
version: 2.5.0
|
38
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
41
|
requirements:
|
40
42
|
- - ">="
|
41
43
|
- !ruby/object:Gem::Version
|
42
44
|
version: '0'
|
43
45
|
requirements: []
|
44
|
-
|
45
|
-
rubygems_version: 2.6.13
|
46
|
+
rubygems_version: 3.1.4
|
46
47
|
signing_key:
|
47
48
|
specification_version: 4
|
48
49
|
summary: Ruby DSL for generating Nomad job specification files
|