diff --git a/command/agent/command.go b/command/agent/command.go
index 6976b9d76..7c3d5ef34 100644
--- a/command/agent/command.go
+++ b/command/agent/command.go
@@ -193,6 +193,23 @@ func (c *Command) readConfig() *Config {
return nil
}
+ // Verify the paths are absolute.
+ dirs := map[string]string{
+ "data-dir": config.DataDir,
+ "alloc-dir": config.Client.AllocDir,
+ "state-dir": config.Client.StateDir,
+ }
+ for k, dir := range dirs {
+ if dir == "" {
+ continue
+ }
+
+ if !filepath.IsAbs(dir) {
+ c.Ui.Error(fmt.Sprintf("%s must be given as an absolute path: got %v", k, dir))
+ return nil
+ }
+ }
+
// Ensure that we have the directories we neet to run.
if config.Server.Enabled && config.DataDir == "" {
c.Ui.Error("Must specify data directory")
diff --git a/website/source/docs/agent/config.html.md b/website/source/docs/agent/config.html.md
index c35ac0a63..386ba64ed 100644
--- a/website/source/docs/agent/config.html.md
+++ b/website/source/docs/agent/config.html.md
@@ -94,7 +94,7 @@ nodes, unless otherwise specified:
directory by default to store temporary allocation data as well as cluster
information. Server nodes use this directory to store cluster state, including
the replicated log and snapshot data. This option is required to start the
- Nomad agent.
+ Nomad agent and must be specified as an absolute path.
* `log_level`: Controls the verbosity of logs the Nomad agent will output. Valid
log levels include `WARN`, `INFO`, or `DEBUG` in increasing order of
@@ -253,14 +253,14 @@ configured on server nodes.
configuration options depend on this value. Defaults to `false`.
* `state_dir`: This is the state dir used to store
client state. By default, it lives inside of the [data_dir](#data_dir), in
- the "client" sub-path.
+ the "client" sub-path. It must be specified as an absolute path.
* `alloc_dir`: A directory used to store allocation data.
Depending on the workload, the size of this directory can grow arbitrarily
large as it is used to store downloaded artifacts for drivers (QEMU images,
JAR files, etc.). It is therefore important to ensure this directory is
placed some place on the filesystem with adequate storage capacity. By
default, this directory lives under the [data_dir](#data_dir) at the
- "alloc" sub-path.
+ "alloc" sub-path. It must be specified as an absolute path.
* `servers`: An array of server addresses. This list is
used to register the client with the server nodes and advertise the
available resources so that the agent can receive work.