From afa62a73a52d197a8eabbc3b3608c3ce8d2635a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lapeyre?= Date: Tue, 29 Sep 2020 18:02:39 +0200 Subject: [PATCH] Document the differences between the Nomad job specification and the Terraform schema --- website/docs/r/job_v2.html.markdown | 102 ++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 15 deletions(-) diff --git a/website/docs/r/job_v2.html.markdown b/website/docs/r/job_v2.html.markdown index 0a9e274e..305811cb 100644 --- a/website/docs/r/job_v2.html.markdown +++ b/website/docs/r/job_v2.html.markdown @@ -25,24 +25,96 @@ Registering a job from a jobspec file: ```hcl resource "nomad_job_v2" "app" { job { - name = "example" - datacenters = ["dc1"] - - group { - name = "cache" - - task { - name = "redis" - driver = "docker" - config = jsonencode({ - image = "redis:3.2" - }) - } - } - } + name = "example" + datacenters = ["dc1"] + + group { + name = "cache" + + task { + name = "redis" + driver = "docker" + config = jsonencode({ + image = "redis:3.2" + }) + } + } + } +} +``` + +The attribute `job` supports the same attributes as the [Nomad Job specification](https://www.nomadproject.io/docs/job-specification) +with the exception of the stanza having an ID: + +```hcl +resource "nomad_job_v2" "app" { + job { + # instead of having + # job "the-job-id" { + # ... + # } + # the id can be specified here: + id = "the-job-id" + + name = "example" + datacenters = ["dc1"] + + # group "cache" {} becomes: + group { + name = "cache" + + # task "server" {} becomes: + task { + name = "redis" + + driver = "docker" + config = jsonencode({ + image = "redis:3.2" + }) + + resources { + # device "nvidia/gpu" {} becomes: + device { + name = "nvidia/gpu" + # ... + } + } + } + + # volume "certs" {} becomes: + volume { + name = "certs" + # ... + } + + network { + # port "http" {} becomes: + port { + label = "http" + # ... + } + } + + spread { + attribute = "$${meta.rack}" + + # target "r1" becomes: + target { + attribute = "r1" + percent = 60 + } + + target { + attribute = "r2" + percent = 40 + } + } + } + } } ``` + ## Argument Reference The following arguments are supported: