From b91b44908b0e091db427d5c1250b45f4b6926bd4 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 6 Apr 2024 16:44:55 +0900 Subject: [PATCH] Deploy `/etc/nomad.d/options.hcl`. --- cookbooks/nomad/files/etc/nomad.d/options.hcl | 23 +++++++++++++++++++ cookbooks/nomad/setup.rb | 8 +++++++ 2 files changed, 31 insertions(+) create mode 100644 cookbooks/nomad/files/etc/nomad.d/options.hcl diff --git a/cookbooks/nomad/files/etc/nomad.d/options.hcl b/cookbooks/nomad/files/etc/nomad.d/options.hcl new file mode 100644 index 0000000..514aec8 --- /dev/null +++ b/cookbooks/nomad/files/etc/nomad.d/options.hcl @@ -0,0 +1,23 @@ +plugin "docker" { + config { + # extra Docker labels to be set by Nomad on each Docker container with the appropriate value + extra_labels = ["job_name", "task_group_name", "task_name", "namespace", "node_name"] + + volumes { + enabled = true + } + + allow_privileged = true + } +} + +client { + host_volume "docker-sock" { + path = "/var/run/docker.sock" + } + + host_volume "tmp" { + path = "/tmp" + } +} + diff --git a/cookbooks/nomad/setup.rb b/cookbooks/nomad/setup.rb index 100a9b3..4aff591 100644 --- a/cookbooks/nomad/setup.rb +++ b/cookbooks/nomad/setup.rb @@ -49,6 +49,14 @@ if node['nomad']['client'] end end + remote_file "/etc/nomad.d/options.hcl" do + mode "0644" + owner "nomad" + group "nomad" + + notifies :restart, 'service[nomad]' + end + directory '/etc/nomad.d/jobs' do owner 'nomad' group 'nomad'