github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/job-specification/dispatch_payload.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: dispatch_payload Stanza - Job Specification
     4  sidebar_title: dispatch_payload
     5  description: |-
     6    The "dispatch_payload" stanza allows a task to access dispatch payloads.
     7    to
     8  ---
     9  
    10  # `dispatch_payload` Stanza
    11  
    12  <Placement groups={['job', 'group', 'task', 'dispatch_payload']} />
    13  
    14  The `dispatch_payload` stanza is used in conjunction with a [`parameterized`][parameterized] job
    15  that expects a payload. When the job is dispatched with a payload, the payload
    16  will be made available to any task that has a `dispatch_payload` stanza. The
    17  payload will be written to the configured file before the task is started. This
    18  allows the task to use the payload as input or configuration.
    19  
    20  ```hcl
    21  job "docs" {
    22    group "example" {
    23      task "server" {
    24        dispatch_payload {
    25          file = "config.json"
    26        }
    27      }
    28    }
    29  }
    30  ```
    31  
    32  ## `dispatch_payload` Parameters
    33  
    34  - `file` `(string: "")` - Specifies the file name to write the content of
    35    dispatch payload to. The file is written relative to the [task's local
    36    directory][localdir].
    37  
    38  ## `dispatch_payload` Examples
    39  
    40  The following examples only show the `dispatch_payload` stanzas. Remember that the
    41  `dispatch_payload` stanza is only valid in the placements listed above.
    42  
    43  ### Write Payload to a File
    44  
    45  This example shows a `dispatch_payload` block in a parameterized job that writes
    46  the payload to a `config.json` file.
    47  
    48  ```hcl
    49  dispatch_payload {
    50    file = "config.json"
    51  }
    52  ```
    53  
    54  [localdir]: /docs/runtime/environment#local 'Task Local Directory'
    55  [parameterized]: /docs/job-specification/parameterized 'Nomad parameterized Job Specification'