Custom Provisioners
A provisioner is a Docker image that runs infrastructure-as-code actions (plan, provision, and decommission) for a step of a bundle. Massdriver's official provisioners are OpenTofu, Terraform, Helm, and Bicep. A custom provisioner, which you build and maintain, can run any other tool.
Custom provisioners are available only in self-hosted installations.
Common reasons to build one:
- Other IaC tools: Pulumi, AWS CDK, ARM templates, CloudFormation, Ansible, or internal tooling.
- Security and compliance tooling: Snyk, Checkov, custom audits, compliance reporting.
- Operational systems: CMDB updates, monitoring configuration, service catalog registration, cost tracking.
Creating a Custom Provisioner​
This example builds an "echo" provisioner that prints its inputs and the action it runs. It provisions nothing.
The official provisioners for OpenTofu, Terraform, Helm and Bicep are complete examples to read or fork.
Step 1: Create the Docker Image​
FROM ubuntu:24.04
# Install your required tools
RUN apt update && apt install -y ca-certificates jq adduser && \
rm -rf /var/lib/apt/lists/*
# Create the working dir
RUN mkdir -p -m 777 /massdriver
# Provisioner pods run as UID 10001
RUN adduser \
--disabled-password \
--gecos "" \
--uid 10001 \
massdriver
RUN chown -R massdriver:massdriver /massdriver
# Copy your entrypoint script - be sure to copy it to /usr/local/bin/entrypoint.sh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Set the /massdriver directory as the default
WORKDIR /massdriver
# Drop privileges to created user
USER massdriver
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
The workflow runs the container with the command entrypoint.sh, so the script must be executable and on the PATH, for example at /usr/local/bin/entrypoint.sh.
Step 2: Create the Entrypoint Script​
Massdriver places the bundle directory and input files in the container before it runs the entrypoint. See Provisioner Overview for the files and environment variables.
#!/bin/bash
set -euo pipefail
# Create bash variables for Massdriver inputs
workdir="/massdriver"
params_path="$workdir/params.json"
dependencies_path="$workdir/dependencies.json"
config_path="$workdir/config.json"
envs_path="$workdir/envs.json"
secrets_path="$workdir/secrets.json"
# Navigate to the proper bundle directory for this step
cd /massdriver/bundle/$MASSDRIVER_STEP_PATH
echo "Starting action: $MASSDRIVER_DEPLOYMENT_ACTION"
case "$MASSDRIVER_DEPLOYMENT_ACTION" in
"plan")
echo "Planning deployment..."
# Implement your plan logic
;;
"provision")
echo "Provisioning resources..."
# Implement your provision logic
;;
"decommission")
echo "Decommissioning resources..."
# Implement your decommission logic
;;
*)
echo "Unknown action: $MASSDRIVER_DEPLOYMENT_ACTION"
exit 1
;;
esac
echo "Action $MASSDRIVER_DEPLOYMENT_ACTION completed successfully."
Step 3: Build and Publish the Image​
Push the image to a registry that the Massdriver cluster can pull from:
# Build the image
docker build -t your-registry.com/provisioner-echo:v1.0.0 .
# Push to registry
docker push your-registry.com/provisioner-echo:v1.0.0
Using Custom Provisioners in Bundles​
Set the image as the step's provisioner in the bundle's massdriver.yaml. Values in the step's config block are written to config.json:
steps:
- path: src
provisioner: your-registry.com/provisioner-echo:v1.0.0
# config:
# foo: .params.foo
Getting Help​
Ask in the Slack community, or contact your Massdriver support team.