Skip to main content

Provisioner Specification

A provisioner is a container image that runs one step of a bundle for a plan, provision, or decommission deployment. Massdriver has four official provisioners:

Self-hosted installations can also run custom provisioners.

Configuration​

The steps block in massdriver.yaml lists the steps a deployment runs and the provisioner for each.

  • path (required): the step's directory in the bundle.
  • provisioner (required): opentofu, terraform, helm, or bicep. Add :<tag> to pin an image tag, such as opentofu:1.10. Without a tag, the step runs the latest image, massdrivercloud/provisioner-<name>:latest.
  • skip_on_delete: true skips the step on decommission, so its cloud resources stay, such as encryption keys.
  • config: provisioner settings. Each provisioner page lists its keys. A string is a jq expression evaluated against the jq context. Booleans and numbers are used as is, and maps are evaluated key by key. An expression that fails or returns null fails the deployment.
  • resources: jq templates that render the step's resources. See Resources.

Steps run in order on plan and provision, and in reverse order on decommission.

Example​

yaml
steps:
- path: src
provisioner: opentofu

- path: chart
provisioner: helm
skip_on_delete: true
config:
namespace: .params.namespace
release_name: .params.release_name

- path: another
provisioner: bicep
skip_on_delete: true
config:
location: .dependencies.azure_credentials.region
resource_group: '@text "foo"'
delete_resource_group: true

The jq context​

config expressions and app.envs expressions run against this object:

KeyHolds
.paramsThe instance's params, plus md_metadata
.dependenciesThe resources that fill the bundle's dependencies, keyed by dependency name

.connections is a deprecated alias for .dependencies. It holds the same data.

yaml
config:
region: .dependencies.azure_credentials.region

The bundle's own resources do not exist yet when these expressions run, so they cannot be read.

md_metadata holds name_prefix, default_tags, and observability.alarm_webhook_url, among others. default_tags always includes managed-by and md-instance. Its other keys come from the organization's default tags setting.

Environment​

Each step runs in its own container. The bundle is at /massdriver/bundle, and the step runs in /massdriver/bundle/<path>.

Inputs​

FileHolds
/massdriver/params.jsonThe instance's params, plus md_metadata
/massdriver/dependencies.jsonThe resources that fill the bundle's dependencies
/massdriver/connections.jsonDeprecated. The same document as dependencies.json
/massdriver/envs.jsonThe resolved app.envs
/massdriver/secrets.jsonThe instance's secrets, decrypted
/massdriver/config.jsonThe step's config, with its jq expressions evaluated
/massdriver/oidc/<level>.jwtDeployment identity tokens, when enabled

Both dependencies.json and connections.json are written for every step, so a custom provisioner can move to the new name when it is ready. The official provisioners still read connections.json.

Environment Variables​

VariableDescription
MASSDRIVER_BUNDLE_NAMEName of the bundle.
MASSDRIVER_BUNDLE_VERSIONVersion of the bundle.
MASSDRIVER_DEPLOYMENT_ACTIONplan, provision, or decommission.
MASSDRIVER_DEPLOYMENT_IDID of the deployment.
MASSDRIVER_INSTANCE_IDIdentifier of the instance, such as api-prod-db.
MASSDRIVER_ORGANIZATION_IDIdentifier of the organization.
MASSDRIVER_ORGANIZATION_UUIDUUID of the organization.
MASSDRIVER_STEP_PATHpath of the current step.
MASSDRIVER_TOKENThe deployment's token for the Massdriver API.
MASSDRIVER_URLBase URL of the Massdriver API.
MASSDRIVER_OIDC_<LEVEL>_TOKEN_FILEPath of each deployment identity token, when enabled.
TRACEPARENTW3C trace context of the deployment.
MASSDRIVER_BUNDLE_IDDeprecated. ID of the bundle release.
MASSDRIVER_MANIFEST_IDDeprecated. ID of the component.
MASSDRIVER_PACKAGE_IDDeprecated. ID of the instance.
MASSDRIVER_PACKAGE_NAMEDeprecated. Name prefix of the instance, such as ecomm-prod-api-0000.
MASSDRIVER_TARGET_MODEDeprecated. Mode of the environment.

Resources​

After a provision, the official provisioners publish the step's resources with jq templates. Each template renders one resource named in the bundle's resources block. Templates come from, in priority order:

  1. steps[].resources.<name>.template in massdriver.yaml
  2. resource_<name>.jq in the step directory
  3. artifact_<name>.jq in the step directory (legacy)

A template reads this object and must return exactly one JSON object:

json
{
"params": {},
"connections": {},
"envs": {},
"secrets": {},
"outputs": {}
}

outputs is what the step produced: the module outputs for OpenTofu and Terraform, the deployment outputs for Bicep, and an array of rendered manifests for Helm. A template for a name that is not declared in resources fails the deployment. The provisioner also deletes any resource of the instance whose name is no longer declared.

On decommission, the provisioner deletes the resources that the step has templates for.

OpenTofu and Terraform steps can also publish resources with the massdriver_resource resource of the Massdriver provider.