Skip to main content
Errand loads all .ern files in the target directory and merges them into one playbook. You can use this to split a large playbook into focused files.

How it works

When you run errand run, Errand reads every .ern file in the directory (non-recursively) and merges their blocks as if they were written in a single file. Variables, computed values, and tasks from different files can reference each other without any imports.

Example

Organize a project by concern, one file per area:
project
variables.ern
test.ern
build.ern
deploy.ern
variables.ern: shared inputs and computed values used by all other files:
variable "app" {
  type    = string
  default = "api"
}

variable "version" {
  type = string
}

computed "image" {
  expression = "${env("CI_REGISTRY", "registry.example.com")}/${var.app}:${var.version}"
}
test.ern
task "test" {
  description = "Run the test suite"
  commands    = ["go test ./..."]
}
build.ern: references task.test from test.ern and computed.image from variables.ern:
task "build" {
  description = "Build and push the Docker image"
  depends_on  = [task.test]
  commands = [
    "docker build -t ${computed.image} .",
    "docker push ${computed.image}",
  ]
}
deploy.ern
task "deploy" {
  description = "Deploy to the cluster"
  depends_on  = [task.build]
  commands    = ["kubectl set image deployment/${var.app} ${var.app}=${computed.image}"]
}

task "default" {
  depends_on = [task.deploy]
  commands   = []
}
Run from the project directory:
errand run --var version=1.4.2

Pointing to a specific directory

By default, Errand loads from the current directory. Use --dir to specify another:
errand run --dir ./ops deploy --var version=1.4.2

Notes

  • Block names must be unique across all files. Declaring task "build" in two files is an error.
  • You can have at most one errand block across all files in the directory.
  • Files in subdirectories are ignored. Only .ern files in the target directory are loaded.
  • Errand does not sort or prioritize files by name. All files are merged before any block is evaluated.