github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/website/source/docs/configuration/index.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Agent Configuration"
     4  sidebar_current: "docs-configuration"
     5  description: |-
     6    Learn about the configuration options available for the Nomad agent.
     7  ---
     8  
     9  # Nomad Configuration
    10  
    11  Nomad agents have a variety of parameters that can be specified via
    12  configuration files or command-line flags. Configuration files are written in
    13  [HCL][hcl]. Nomad can read and combine parameters from multiple configuration
    14  files or directories to configure the Nomad agent.
    15  
    16  ## Load Order and Merging
    17  
    18  The Nomad agent supports multiple configuration files, which can be provided
    19  using the `-config` CLI flag. The flag can accept either a file or folder. In
    20  the case of a folder, any `.hcl` and `.json` files in the folder will be loaded
    21  and merged in lexicographical order. Directories are not loaded recursively.
    22  
    23  For example:
    24  
    25  ```shell
    26  $ nomad agent -config=server.conf -config=/etc/nomad -config=extra.json
    27  ```
    28  
    29  This will load configuration from `server.conf`, from `.hcl` and `.json` files
    30  under `/etc/nomad`, and finally from `extra.json`.
    31  
    32  As each file is processed, its contents are merged into the existing
    33  configuration. When merging, any non-empty values from the latest config file
    34  will append or replace parameters in the current configuration. An empty value
    35  means `""` for strings, `0` for integer or float values, and `false` for
    36  booleans. Since empty values are ignored you cannot disable an parameter like
    37  `server` mode once you've enabled it.
    38  
    39  Here is an example Nomad agent configuration that runs in both client and server
    40  mode.
    41  
    42  ```hcl
    43  data_dir  = "/var/lib/nomad"
    44  
    45  bind_addr = "0.0.0.0" # the default
    46  
    47  advertise {
    48    # Defaults to the first private IP address.
    49    http = "1.2.3.4"
    50    rpc  = "1.2.3.4"
    51    serf = "1.2.3.4:5648" # non-default ports may be specified
    52  }
    53  
    54  server {
    55    enabled          = true
    56    bootstrap_expect = 3
    57  }
    58  
    59  client {
    60    enabled       = true
    61    network_speed = 10
    62    options {
    63      "driver.raw_exec.enable" = "1"
    64    }
    65  }
    66  
    67  consul {
    68    address = "1.2.3.4:8500"
    69  }
    70  
    71  ```
    72  
    73  ~> Note that it is strongly recommended **not** to operate a node as both
    74  `client` and `server`, although this is supported to simplify development and
    75  testing.
    76  
    77  ## General Parameters
    78  
    79  - `acl` <code>([ACL][acl]: nil)</code> - Specifies configuration which is specific to ACLs.
    80  
    81  - `addresses` `(Addresses: see below)` - Specifies the bind address for
    82    individual network services. Any values configured in this stanza take
    83    precedence over the default [bind_addr](#bind_addr).
    84    The values support [go-sockaddr/template format][go-sockaddr/template].
    85  
    86    - `http` - The address the HTTP server is bound to. This is the most common
    87      bind address to change.
    88  
    89    - `rpc` - The address to bind the internal RPC interfaces to. Should be
    90      exposed only to other cluster members if possible.
    91  
    92    - `serf` - The address used to bind the gossip layer to. Both a TCP and UDP
    93      listener will be exposed on this address. Should be exposed only to other
    94      cluster members if possible.
    95  
    96  - `advertise` `(Advertise: see below)` - Specifies the advertise address for
    97    individual network services. This can be used to advertise a different address
    98    to the peers of a server or a client node to support more complex network
    99    configurations such as NAT. This configuration is optional, and defaults to
   100    the bind address of the specific network service if it is not provided. Any
   101    values configured in this stanza take precedence over the default
   102    [bind_addr](#bind_addr).
   103  
   104      If the bind address is `0.0.0.0` then the address
   105    private IP found is advertised. You may advertise an alternate port as well.
   106    The values support [go-sockaddr/template format][go-sockaddr/template].
   107  
   108    - `http` - The address to advertise for the HTTP interface. This should be
   109      reachable by all the nodes from which end users are going to use the Nomad
   110      CLI tools.
   111  
   112    - `rpc` - The address advertised to Nomad client nodes. This allows
   113      advertising a different RPC address than is used by Nomad Servers such that
   114      the clients can connect to the Nomad servers if they are behind a NAT.
   115  
   116    - `serf` - The address advertised for the gossip layer. This address must be
   117      reachable from all server nodes. It is not required that clients can reach
   118      this address. Nomad servers will communicate to each other over RPC using
   119      the advertised Serf IP and advertised RPC Port.
   120  
   121  - `bind_addr` `(string: "0.0.0.0")` - Specifies which address the Nomad
   122    agent should bind to for network services, including the HTTP interface as
   123    well as the internal gossip protocol and RPC mechanism. This should be
   124    specified in IP format, and can be used to easily bind all network services to
   125    the same address. It is also possible to bind the individual services to
   126    different addresses using the [addresses](#addresses) configuration option.
   127    Dev mode (`-dev`) defaults to localhost.
   128    The value supports [go-sockaddr/template format][go-sockaddr/template].
   129  
   130  - `client` <code>([Client][client]: nil)</code> - Specifies configuration which is specific to the Nomad client.
   131  
   132  - `consul` <code>([Consul][consul]: nil)</code> - Specifies configuration for
   133    connecting to Consul.
   134  
   135  - `datacenter` `(string: "dc1")` - Specifies the data center of the local agent.
   136    All members of a datacenter should share a local LAN connection.
   137  
   138  - `data_dir` `(string: required)` - Specifies a local directory used to store
   139    agent state. Client nodes use this directory by default to store temporary
   140    allocation data as well as cluster information. Server nodes use this
   141    directory to store cluster state, including the replicated log and snapshot
   142    data. This must be specified as an absolute path.
   143    
   144        ~> **WARNING**: This directory **must not** be set to a directory that is [included in the chroot](/docs/drivers/exec.html#chroot) if you use the [`exec`](/docs/drivers/exec.html) driver.
   145  
   146  - `disable_anonymous_signature` `(bool: false)` - Specifies if Nomad should
   147    provide an anonymous signature for de-duplication with the update check.
   148  
   149  - `disable_update_check` `(bool: false)` - Specifies if Nomad should not check for updates and security bulletins.
   150  
   151  - `enable_debug` `(bool: false)` - Specifies if the debugging HTTP endpoints
   152    should be enabled. These endpoints can be used with profiling tools to dump
   153    diagnostic information about Nomad's internals.
   154  
   155  - `enable_syslog` `(bool: false)` - Specifies if the agent should log to syslog.
   156    This option only works on Unix based systems.
   157  
   158  - `http_api_response_headers` `(map<string|string>: nil)` - Specifies
   159    user-defined headers to add to the HTTP API responses.
   160  
   161  - `leave_on_interrupt` `(bool: false)` - Specifies if the agent should
   162    gracefully leave when receiving the interrupt signal. By default, the agent
   163    will exit forcefully on any signal. This value should only be set to true on
   164    server agents if it is expected that a terminated server instance will never
   165    join the cluster again.
   166  
   167  - `leave_on_terminate` `(bool: false)` - Specifies if the agent should
   168    gracefully leave when receiving the terminate signal. By default, the agent
   169    will exit forcefully on any signal. This value should only be set to true on
   170    server agents if it is expected that a terminated server instance will never
   171    join the cluster again.
   172  
   173  - `log_level` `(string: "INFO")` - Specifies  the verbosity of logs the Nomad
   174    agent will output. Valid log levels include `WARN`, `INFO`, or `DEBUG` in
   175    increasing order of verbosity.
   176  
   177  - `log_json` `(bool: false)` - Output logs in a JSON format.
   178  
   179  - `name` `(string: [hostname])` - Specifies the name of the local node. This
   180    value is used to identify individual agents. When specified on a server, the
   181    name must be unique within the region.
   182  
   183  - `plugin_dir` `(string: "[data_dir]/plugins")` - Specifies the directory to
   184    use for looking up plugins. By default, this is the top-level
   185    [data_dir](#data_dir) suffixed with "plugins", like `"/opt/nomad/plugins"`.
   186    This must be an absolute path.
   187  
   188  - `plugin` <code>([Plugin][plugin]: nil)</code> - Specifies configuration for a
   189    specific plugin. The plugin stanza may be repeated, once for each plugin being
   190    configured. The key of the stanza is the plugin's executable name relative to
   191    the [plugin_dir](#plugin_dir).
   192  
   193  - `ports` `(Port: see below)` - Specifies the network ports used for different
   194    services required by the Nomad agent.
   195  
   196    - `http` - The port used to run the HTTP server.
   197  
   198    - `rpc` - The port used for internal RPC communication between
   199      agents and servers, and for inter-server traffic for the consensus algorithm
   200      (raft).
   201  
   202    - `serf` - The port used for the gossip protocol for cluster
   203      membership. Both TCP and UDP should be routable between the server nodes on
   204      this port.
   205  
   206      The default values are:
   207  
   208      ```hcl
   209      ports {
   210        http = 4646
   211        rpc  = 4647
   212        serf = 4648
   213      }
   214      ```
   215  
   216  - `region` `(string: "global")` - Specifies the region the Nomad agent is a
   217    member of. A region typically maps to a geographic region, for example `us`,
   218    with potentially multiple zones, which map to [datacenters](#datacenter) such
   219    as `us-west` and `us-east`.
   220  
   221  - `sentinel` <code>([Sentinel][sentinel]: nil)</code> - Specifies configuration for Sentinel policies.
   222  
   223  - `server` <code>([Server][server]: nil)</code> - Specifies configuration which is specific to the Nomad server.
   224  
   225  - `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to write to. This has no effect unless `enable_syslog` is true.
   226  
   227  - `tls` <code>([TLS][tls]: nil)</code> - Specifies configuration for TLS.
   228  
   229  - `vault` <code>([Vault][vault]: nil)</code> - Specifies configuration for
   230    connecting to Vault.
   231  
   232  ## Examples
   233  
   234  ### Custom Region and Datacenter
   235  
   236  This example shows configuring a custom region and data center for the Nomad
   237  agent:
   238  
   239  ```hcl
   240  region     = "europe"
   241  datacenter = "ams"
   242  ```
   243  
   244  ### Enable CORS
   245  
   246  This example shows how to enable CORS on the HTTP API endpoints:
   247  
   248  ```hcl
   249  http_api_response_headers {
   250    "Access-Control-Allow-Origin" = "*"
   251  }
   252  ```
   253  
   254  [hcl]: https://github.com/hashicorp/hcl "HashiCorp Configuration Language"
   255  [go-sockaddr/template]: https://godoc.org/github.com/hashicorp/go-sockaddr/template
   256  [consul]: /docs/configuration/consul.html "Nomad Agent consul Configuration"
   257  [vault]: /docs/configuration/vault.html "Nomad Agent vault Configuration"
   258  [tls]: /docs/configuration/tls.html "Nomad Agent tls Configuration"
   259  [client]: /docs/configuration/client.html "Nomad Agent client Configuration"
   260  [sentinel]: /docs/configuration/sentinel.html "Nomad Agent sentinel Configuration"
   261  [server]: /docs/configuration/server.html "Nomad Agent server Configuration"
   262  [acl]: /docs/configuration/acl.html "Nomad Agent ACL Configuration"
   263  [plugin]: /docs/configuration/plugin.html "Nomad Agent Plugin Configuration"