capistrano-nomad 0.6.0 → 0.6.2
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/Gemfile.lock +1 -1
- data/README.md +17 -3
- data/capistrano-nomad.gemspec +1 -1
- data/lib/capistrano/nomad/helpers/dsl.rb +1 -18
- data/lib/capistrano/nomad/helpers/nomad.rb +12 -2
- 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: 25b29aaa6c532b6656df34b6ebc7ebc23359c4acb3ae2b8c5d7320a2e79c7f66
|
4
|
+
data.tar.gz: 770838795fb494f1c4305168d6b60f51be7f1d33bec9c31e45b7d119ecd427f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24cd34d64db04c41e6b2e39ced4e84129e4fb3ff2d70a25e53d945e2bcdaf35e7a45f6783c1e5cd37d061053ba24b2717d939f6b3e0cd0939c14bc8f39def70d
|
7
|
+
data.tar.gz: e978fbbf7205ed2d160e2702ae9109ba73722c695f9de2e0c8f51cc010a248da5ffbed583d452e1bcc7a6e0ee22989202afd183430256ae73cc7f0f4515d83fa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,10 +34,21 @@ install_plugin Capistrano::Nomad
|
|
34
34
|
Within `deploy.rb`
|
35
35
|
|
36
36
|
```ruby
|
37
|
+
set :nomad_jobs_path, "nomad/jobs"
|
38
|
+
set :nomad_var_files_path, "nomad/vars"
|
39
|
+
|
40
|
+
# Accessible in all .erb files
|
41
|
+
set :nomad_erb_vars, (lambda do
|
42
|
+
{
|
43
|
+
env_name: fetch(:stage).to_sym,
|
44
|
+
domain: fetch(:domain),
|
45
|
+
foo: "bar,"
|
46
|
+
}
|
47
|
+
end)
|
37
48
|
|
38
49
|
# Docker image types
|
39
|
-
nomad_docker_image_type :
|
40
|
-
path: "backend",
|
50
|
+
nomad_docker_image_type :backend,
|
51
|
+
path: "local/path/backend",
|
41
52
|
alias: ->(image_type:) { "gcr.io/axsuul/#{image_type}" },
|
42
53
|
target: "release",
|
43
54
|
build_args: { foo: "bar" }
|
@@ -46,8 +57,11 @@ nomad_docker_image_type :redis,
|
|
46
57
|
alias: "gcr.io/axsuul/redis"
|
47
58
|
|
48
59
|
# Jobs
|
49
|
-
nomad_job :
|
60
|
+
nomad_job :frontend
|
61
|
+
nomad_job :backend, docker_image_types: [:backend], var_files: [:rails]
|
50
62
|
nomad_job :redis, docker_image_types: [:redis]
|
63
|
+
nomad_job :"traefik-default", template: :traefik, erb_vars: { role: :default }
|
64
|
+
nomad_job :"traefik-secondary", template: :traefik, erb_vars: { role: :secondary }
|
51
65
|
|
52
66
|
nomad_namespace :analytics do
|
53
67
|
nomad_job :grafana
|
data/capistrano-nomad.gemspec
CHANGED
@@ -90,24 +90,7 @@ def nomad_job(name, attributes = {})
|
|
90
90
|
|
91
91
|
desc "Restart #{description_name} job"
|
92
92
|
task :restart do
|
93
|
-
|
94
|
-
# We can't restart the job directly so we'll need to fetch all its running allocs and restart each of one
|
95
|
-
# individually instead
|
96
|
-
running_alloc_ids_output = capistrano_nomad_capture_nomad_command(
|
97
|
-
:job,
|
98
|
-
:allocs,
|
99
|
-
{
|
100
|
-
namespace: namespace,
|
101
|
-
t: "'{{range .}}{{if eq .ClientStatus \"running\"}}{{ println .ID}}{{end}}{{end}}'",
|
102
|
-
},
|
103
|
-
name,
|
104
|
-
)
|
105
|
-
running_alloc_ids = running_alloc_ids_output.strip.split("\n")
|
106
|
-
|
107
|
-
running_alloc_ids.each do |alloc_id|
|
108
|
-
capistrano_nomad_execute_nomad_command(:alloc, :restart, alloc_id)
|
109
|
-
end
|
110
|
-
end
|
93
|
+
capistrano_nomad_restart_jobs([name], namespace: namespace)
|
111
94
|
end
|
112
95
|
|
113
96
|
desc "Open console to #{description_name} job. Specify task by passing TASK environment variable"
|
@@ -35,6 +35,10 @@ class CapistranoNomadErbNamespace
|
|
35
35
|
# rubocop:enable Style/MissingRespondToMissing
|
36
36
|
end
|
37
37
|
|
38
|
+
def capistrano_nomad_ensure_absolute_path(path)
|
39
|
+
path[0] == "/" ? path : "/#{path}"
|
40
|
+
end
|
41
|
+
|
38
42
|
def capistrano_nomad_build_file_path(parent_path, basename, namespace: nil)
|
39
43
|
segments = [parent_path]
|
40
44
|
segments << namespace if namespace
|
@@ -71,11 +75,11 @@ def capistrano_nomad_build_local_var_file_path(name, *args)
|
|
71
75
|
end
|
72
76
|
|
73
77
|
def capistrano_nomad_build_release_job_path(*args)
|
74
|
-
"#{release_path}#{capistrano_nomad_build_base_job_path(*args)}"
|
78
|
+
"#{release_path}#{capistrano_nomad_ensure_absolute_path(capistrano_nomad_build_base_job_path(*args))}"
|
75
79
|
end
|
76
80
|
|
77
81
|
def capistrano_nomad_build_release_var_file_path(*args)
|
78
|
-
"#{release_path}#{capistrano_nomad_build_base_var_file_path(*args)}"
|
82
|
+
"#{release_path}#{capistrano_nomad_ensure_absolute_path(capistrano_nomad_build_base_var_file_path(*args))}"
|
79
83
|
end
|
80
84
|
|
81
85
|
def capistrano_nomad_run_nomad_command(kind, *args)
|
@@ -317,6 +321,12 @@ def capistrano_nomad_deploy_jobs(names, *args)
|
|
317
321
|
capistrano_nomad_upload_run_jobs(names, *args)
|
318
322
|
end
|
319
323
|
|
324
|
+
def capistrano_nomad_restart_jobs(names, namespace: nil)
|
325
|
+
names.each do |name|
|
326
|
+
capistrano_nomad_execute_nomad_command(:job, :restart, { namespace: namespace }, name)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
320
330
|
def capistrano_nomad_purge_jobs(names, namespace: nil, is_detached: true)
|
321
331
|
names.each do |name|
|
322
332
|
capistrano_nomad_execute_nomad_command(:stop, { namespace: namespace, purge: true, detach: is_detached }, name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-nomad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Hu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|