github.com/diptanu/nomad@v0.5.7-0.20170516172507-d72e86cbe3d9/website/source/docs/agent/configuration/index.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Agent Configuration"
     4  sidebar_current: "docs-agent-configuration"
     5  description: |-
     6    Learn about the configuration options available for the Nomad agent.
     7  ---
     8  
     9  # Agent 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:
    20  
    21  ```shell
    22  $ nomad agent -config=server.conf -config=/etc/nomad -config=extra.json
    23  ```
    24  
    25  This will load configuration from `server.conf`, from `.hcl` and `.json` files
    26  under `/etc/nomad`, and finally from `extra.json`. Files are loaded and merged
    27  in lexicographical order. Directories are not loaded recursively.
    28  
    29  As each file is processed, its contents are merged into the existing
    30  configuration. When merging, any non-empty values from the latest config file
    31  will append or replace parameters in the current configuration. An empty value
    32  means `""` for strings, `0` for integer or float values, and `false` for
    33  booleans. Since empty values are ignored you cannot disable an parameter like
    34  `server` mode once you've enabled it.
    35  
    36  Here is an example Nomad agent configuration that runs in both client and server
    37  mode.
    38  
    39  ```hcl
    40  bind_addr = "0.0.0.0" # the default
    41  
    42  data_dir  = "/var/lib/nomad"
    43  
    44  advertise {
    45    # Defaults to the node's hostname. If the hostname resolves to a loopback
    46    # address you must manually configure advertise addresses.
    47    http = "1.2.3.4"
    48    rpc  = "1.2.3.4"
    49    serf = "1.2.3.4:5648" # non-default ports may be specified
    50  }
    51  
    52  server {
    53    enabled          = true
    54    bootstrap_expect = 3
    55  }
    56  
    57  client {
    58    enabled       = true
    59    network_speed = 10
    60    options {
    61      "driver.raw_exec.enable" = "1"
    62    }
    63  }
    64  
    65  consul {
    66    address = "1.2.3.4:8500"
    67  }
    68  
    69  atlas {
    70    infrastructure = "hashicorp/mars"
    71    token          = "atlas.v1.AFE84330943"
    72  }
    73  ```
    74  
    75  ~> Note that it is strongly recommended **not** to operate a node as both
    76  `client` and `server`, although this is supported to simplify development and
    77  testing.
    78  
    79  ## General Parameters
    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). If the bind address is `0.0.0.0` then the hostname
   103    is advertised. You may advertise an alternate port as well.
   104    The values support [go-sockaddr/template format][go-sockaddr/template].
   105  
   106    - `http` - The address to advertise for the HTTP interface. This should be
   107      reachable by all the nodes from which end users are going to use the Nomad
   108      CLI tools.
   109  
   110    - `rpc` - The address to advertise for the RPC interface. This address should
   111      be reachable by all of the agents in the cluster.
   112  
   113    - `serf` - The address advertised for the gossip layer. This address must be
   114      reachable from all server nodes. It is not required that clients can reach
   115      this address.
   116  
   117  - `atlas` <code>([Atlas][atlas]: nil)</code> - Specifies if Nomad should connect
   118    to Nomad Enterprise and Atlas.
   119  
   120  - `bind_addr` `(string: "0.0.0.0")` - Specifies which address the Nomad
   121    agent should bind to for network services, including the HTTP interface as
   122    well as the internal gossip protocol and RPC mechanism. This should be
   123    specified in IP format, and can be used to easily bind all network services to
   124    the same address. It is also possible to bind the individual services to
   125    different addresses using the [addresses](#addresses) configuration option.
   126    Dev mode (`-dev`) defaults to localhost.
   127    The value supports [go-sockaddr/template format][go-sockaddr/template].
   128  
   129  - `client` <code>([Client][client]: nil)</code> - Specifies configuration which is specific to the Nomad client.
   130  
   131  - `consul` <code>([Consul][consul]: nil)</code> - Specifies configuration for
   132    connecting to Consul.
   133  
   134  - `datacenter` `(string: "dc1")` - Specifies the data center of the local agent.
   135    All members of a datacenter should share a local LAN connection.
   136  
   137  - `data_dir` `(string: required)` - Specifies a local directory used to store
   138    agent state. Client nodes use this directory by default to store temporary
   139    allocation data as well as cluster information. Server nodes use this
   140    directory to store cluster state, including the replicated log and snapshot
   141    data. This must be specified as an absolute path.
   142  
   143  - `disable_anonymous_signature` `(bool: false)` - Specifies if Nomad should
   144    provide an anonymous signature for de-duplication with the update check.
   145  
   146  - `disable_update_check` `(bool: false)` - Specifies if Nomad should not check for updates and security bulletins.
   147  
   148  - `enable_debug` `(bool: false)` - Specifies if the debugging HTTP endpoints
   149    should be enabled. These endpoints can be used with profiling tools to dump
   150    diagnostic information about Nomad's internals.
   151  
   152  - `enable_syslog` `(bool: false)` - Specifies if the agent should log to syslog.
   153    This option only works on Unix based systems.
   154  
   155  - `http_api_response_headers` `(map<string|string>: nil)` - Specifies
   156    user-defined headers to add to the HTTP API responses.
   157  
   158  - `leave_on_interrupt` `(bool: false)` - Specifies if the agent should
   159    gracefully leave when receiving the interrupt signal. By default, the agent
   160    will exit forcefully on any signal.
   161  
   162  - `leave_on_terminate` `(bool: false)` - Specifies if the agent should
   163    gracefully leave when receiving the terminate signal. By default, the agent
   164    will exit forcefully on any signal.
   165  
   166  - `log_level` `(string: "INFO")` - Specifies  the verbosity of logs the Nomad
   167    agent will output. Valid log levels include `WARN`, `INFO`, or `DEBUG` in
   168    increasing order of verbosity.
   169  
   170  - `name` `(string: [hostname])` - Specifies the name of the local node. This
   171    value is used to identify individual nodes in a given datacenter and must be
   172    unique per-datacenter.
   173  
   174  - `ports` `(Port: see below)` - Specifies the network ports used for different
   175    services required by the Nomad agent.
   176  
   177    - `http` - The port used to run the HTTP server.
   178  
   179    - `rpc` - The port used for internal RPC communication between
   180      agents and servers, and for inter-server traffic for the consensus algorithm
   181      (raft).
   182  
   183    - `serf` - The port used for the gossip protocol for cluster
   184      membership. Both TCP and UDP should be routable between the server nodes on
   185      this port.
   186  
   187      The default values are:
   188  
   189      ```hcl
   190      ports {
   191        http = 4646
   192        rpc  = 4647
   193        serf = 4648
   194      }
   195      ```
   196  
   197  - `region` `(string: "global")` - Specifies the region the Nomad agent is a
   198    member of. A region typically maps to a geographic region, for example `us`,
   199    with potentially multiple zones, which map to [datacenters](#datacenter) such
   200    as `us-west` and `us-east`.
   201  
   202  - `server` <code>([Server][server]: nil)</code> - Specifies configuration which is specific to the Nomad server.
   203  
   204  - `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to write to. This has no effect unless `enable_syslog` is true.
   205  
   206  - `tls` <code>([TLS][tls]: nil)</code> - Specifies configuration for TLS.
   207  
   208  - `vault` <code>([Vault][vault]: nil)</code> - Specifies configuration for
   209    connecting to Vault.
   210  
   211  ## Examples
   212  
   213  ### Custom Region and Datacenter
   214  
   215  This example shows configuring a custom region and data center for the Nomad
   216  agent:
   217  
   218  ```hcl
   219  region     = "europe"
   220  datacenter = "ams"
   221  ```
   222  
   223  ### Enable CORS
   224  
   225  This example shows how to enable CORS on the HTTP API endpoints:
   226  
   227  ```hcl
   228  http_api_response_headers {
   229    "Access-Control-Allow-Origin" = "*"
   230  }
   231  ```
   232  
   233  [hcl]: https://github.com/hashicorp/hcl "HashiCorp Configuration Language"
   234  [go-sockaddr/template]: https://godoc.org/github.com/hashicorp/go-sockaddr/template
   235  [consul]: /docs/agent/configuration/consul.html "Nomad Agent consul Configuration"
   236  [atlas]: /docs/agent/configuration/atlas.html "Nomad Agent atlas Configuration"
   237  [vault]: /docs/agent/configuration/vault.html "Nomad Agent vault Configuration"
   238  [tls]: /docs/agent/configuration/tls.html "Nomad Agent tls Configuration"
   239  [client]: /docs/agent/configuration/client.html "Nomad Agent client Configuration"
   240  [server]: /docs/agent/configuration/server.html "Nomad Agent server Configuration"