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