github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/nomad/r/job.html.markdown (about)

     1  ---
     2  layout: "nomad"
     3  page_title: "Nomad: nomad_job"
     4  sidebar_current: "docs-nomad-resource-job"
     5  description: |-
     6    Manages a job registered in Nomad.
     7  ---
     8  
     9  # nomad_job
    10  
    11  Manages a job registered in Nomad.
    12  
    13  This can be used to initialize your cluster with system jobs, common services,
    14  and more. In day to day Nomad use it is common for developers to submit
    15  jobs to Nomad directly, such as for general app deployment. In addition to
    16  these apps, a Nomad cluster often runs core system services that are ideally
    17  setup during infrastructure creation. This resource is ideal for the latter
    18  type of job, but can be used to manage any job within Nomad.
    19  
    20  ## Example Usage
    21  
    22  Registering a job from a jobspec file:
    23  
    24  ```hcl
    25  resource "nomad_job" "app" {
    26    jobspec = "${file("${path.module}/job.hcl")}"
    27  }
    28  ```
    29  
    30  Registering a job from an inline jobspec. This is less realistic but
    31  is an example of how it is possible. More likely, the contents will
    32  be paired with something such as the
    33  [template_file](https://www.terraform.io/docs/providers/template/d/file.html)
    34  resource to render parameterized jobspecs.
    35  
    36  ```hcl
    37  resource "nomad_job" "app" {
    38    jobspec = <<EOT
    39  job "foo" {
    40    datacenters = ["dc1"]
    41    type = "service"
    42    group "foo" {
    43      task "foo" {
    44        driver = "raw_exec"
    45        config {
    46          command = "/bin/sleep"
    47          args = ["1"]
    48        }
    49  
    50        resources {
    51          cpu = 20
    52          memory = 10
    53        }
    54  
    55        logs {
    56          max_files = 3
    57          max_file_size = 10
    58        }
    59      }
    60    }
    61  }
    62  EOT
    63  }
    64  ```
    65  
    66  ## Argument Reference
    67  
    68  The following arguments are supported:
    69  
    70  * `jobspec` - (Required) The contents of the jobspec to register.
    71  
    72  * `deregister_on_destroy` - (Optional) If true, the job will be deregistered
    73    when this resource is destroyed in Terraform. Defaults to true.
    74  
    75  * `deregister_on_id_change` - (Optional) If true, the job will be deregistered
    76    if the ID of the job in the jobspec changes. Defaults to true.