github.com/maier/nomad@v0.4.1-0.20161110003312-a9e3d0b8549d/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"
    41  data_dir  = "/var/lib/nomad"
    42  
    43  advertise {
    44    # We need to specify our host's IP because we can't
    45    # advertise 0.0.0.0 to other nodes in our cluster.
    46    rpc = "1.2.3.4:4647"
    47  }
    48  
    49  server {
    50    enabled          = true
    51    bootstrap_expect = 3
    52  }
    53  
    54  client {
    55    enabled       = true
    56    network_speed = 10
    57    options {
    58      "driver.raw_exec.enable" = "1"
    59    }
    60  }
    61  
    62  consul {
    63    address = "1.2.3.4:8500"
    64  }
    65  
    66  atlas {
    67    infrastructure = "hashicorp/mars"
    68    token          = "atlas.v1.AFE84330943"
    69  }
    70  ```
    71  
    72  ~> Note that it is strongly recommended **not** to operate a node as both
    73  `client` and `server`, although this is supported to simplify development and
    74  testing.
    75  
    76  ## General Parameters
    77  
    78  - `addresses` `(Addresses: see below)` - Specifies the bind address for
    79    individual network services. Any values configured in this stanza take
    80    precedence over the default [bind_addr](#bind_addr).
    81  
    82    - `http` - The address the HTTP server is bound to. This is the most common
    83      bind address to change.
    84  
    85    - `rpc` - The address to bind the internal RPC interfaces to. Should be
    86      exposed only to other cluster members if possible.
    87  
    88    - `serf` - The address used to bind the gossip layer to. Both a TCP and UDP
    89      listener will be exposed on this address. Should be exposed only to other
    90      cluster members if possible.
    91  
    92  - `advertise` `(Advertise: see below)` - Specifies the advertise address for
    93    individual network services. This can be used to advertise a different address
    94    to the peers of a server or a client node to support more complex network
    95    configurations such as NAT. This configuration is optional, and defaults to
    96    the bind address of the specific network service if it is not provided. Any
    97    values configured in this stanza take precedence over the default
    98    [bind_addr](#bind_addr).
    99  
   100    - `http` - The address to advertise for the HTTP interface. This should be
   101      reachable by all the nodes from which end users are going to use the Nomad
   102      CLI tools.
   103  
   104    - `rpc` - The address to advertise for the RPC interface. This address should
   105      be reachable by all of the agents in the cluster.
   106  
   107    - `serf` - The address advertised for the gossip layer. This address must be
   108      reachable from all server nodes. It is not required that clients can reach
   109      this address.
   110  
   111  - `atlas` <code>([Atlas][atlas]: nil)</code> - Specifies if Nomad should connect
   112    to Nomad Enterprise and Atlas.
   113  
   114  - `bind_addr` `(string: "127.0.0.1")` - Specifies which address the Nomad
   115    agent should bind to for network services, including the HTTP interface as
   116    well as the internal gossip protocol and RPC mechanism. This should be
   117    specified in IP format, and can be used to easily bind all network services to
   118    the same address. It is also possible to bind the individual services to
   119    different addresses using the [addresses](#addresses) configuration option.
   120  
   121  - `client` <code>([Client][client]: nil)</code> - Specifies configuration which is specific to the Nomad client.
   122  
   123  - `consul` <code>([Consul][consul]: nil)</code> - Specifies configuration for
   124    connecting to Consul.
   125  
   126  - `datacenter` `(string: "dc1")` - Specifies the data center of the local agent.
   127    All members of a datacenter should share a local LAN connection.
   128  
   129  - `data_dir` `(string: required)` - Specifies a local directory used to store
   130    agent state. Client nodes use this directory by default to store temporary
   131    allocation data as well as cluster information. Server nodes use this
   132    directory to store cluster state, including the replicated log and snapshot
   133    data. This must be specified as an absolute path.
   134  
   135  - `disable_anonymous_signature` `(bool: false)` - Specifies if Nomad should
   136    provide an anonymous signature for de-duplication with the update check.
   137  
   138  - `disable_update_check` `(bool: false)` - Specifies if Nomad should not check for updates and security bulletins.
   139  
   140  - `enable_debug` `(bool: false)` - Specifies if the debugging HTTP endpoints
   141    should be enabled. These endpoints can be used with profiling tools to dump
   142    diagnostic information about Nomad's internals.
   143  
   144  - `enable_syslog` `(bool: false)` - Specifies if the agent should log to syslog.
   145    This option only works on Unix based systems.
   146  
   147  - `http_api_response_headers` `(map<string|string>: nil)` - Specifies
   148    user-defined headers to add to the HTTP API responses.
   149  
   150  - `leave_on_interrupt` `(bool: false)` - Specifies if the agent should
   151    gracefully leave when receiving the interrupt signal. By default, the agent
   152    will exit forcefully on any signal.
   153  
   154  - `leave_on_terminate` `(bool: false)` - Specifies if the agent should
   155    gracefully leave when receiving the terminate signal. By default, the agent
   156    will exit forcefully on any signal.
   157  
   158  - `log_level` `(string: "INFO")` - Specifies  the verbosity of logs the Nomad
   159    agent will output. Valid log levels include `WARN`, `INFO`, or `DEBUG` in
   160    increasing order of verbosity.
   161  
   162  - `name` `(string: [hostname])` - Specifies the name of the local node. This
   163    value is used to identify individual nodes in a given datacenter and must be
   164    unique per-datacenter.
   165  
   166  - `ports` `(Port: see below)` - Specifies the network ports used for different
   167    services required by the Nomad agent.
   168  
   169    - `http` - The port used to run the HTTP server.
   170  
   171    - `rpc` - The port used for internal RPC communication between
   172      agents and servers, and for inter-server traffic for the consensus algorithm
   173      (raft).
   174  
   175    - `serf` - The port used for the gossip protocol for cluster
   176      membership. Both TCP and UDP should be routable between the server nodes on
   177      this port.
   178  
   179      The default values are:
   180  
   181      ```hcl
   182      ports {
   183        http = 4646
   184        rpc  = 4647
   185        serf = 4648
   186      }
   187      ```
   188  
   189  - `region` `(string: "global")` - Specifies the region the Nomad agent is a
   190    member of. A region typically maps to a geographic region, for example `us`,
   191    with potentially multiple zones, which map to [datacenters](#datacenter) such
   192    as `us-west` and `us-east`.
   193  
   194  - `server` <code>([Server][server]: nil)</code> - Specifies configuration which is specific to the Nomad server.
   195  
   196  - `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to write to. This has no effect unless `enable_syslog` is true.
   197  
   198  - `tls` <code>([TLS][tls]: nil)</code> - Specifies configuration for TLS.
   199  
   200  - `vault` <code>([Vault][vault]: nil)</code> - Specifies configuration for
   201    connecting to Vault.
   202  
   203  ## Examples
   204  
   205  ### Custom Region and Datacenter
   206  
   207  This example shows configuring a custom region and data center for the Nomad
   208  agent:
   209  
   210  ```hcl
   211  region     = "europe"
   212  datacenter = "ams"
   213  ```
   214  
   215  ### Enable CORS
   216  
   217  This example shows how to enable CORS on the HTTP API endpoints:
   218  
   219  ```hcl
   220  http_api_response_headers {
   221    "Access-Control-Allow-Origin" = "*"
   222  }
   223  ```
   224  
   225  [hcl]: https://github.com/hashicorp/hcl "HashiCorp Configuration Language"
   226  [consul]: /docs/agent/configuration/consul.html "Nomad Agent consul Configuration"
   227  [atlas]: /docs/agent/configuration/atlas.html "Nomad Agent atlas Configuration"
   228  [vault]: /docs/agent/configuration/vault.html "Nomad Agent vault Configuration"
   229  [tls]: /docs/agent/configuration/tls.html "Nomad Agent tls Configuration"
   230  [client]: /docs/agent/configuration/client.html "Nomad Agent client Configuration"
   231  [server]: /docs/agent/configuration/server.html "Nomad Agent server Configuration"