Sub topic 9
Organizing Configuration Across Multiple Files
This chapter assumes you can read YAML, have written a basic databricks.yml with a job and targets, and know how bundle variables work. Here you will split a growing bundle into several files with include.
Why split the configuration
A single databricks.yml is fine for one job. Once a project has several jobs, a pipeline, and per-target settings, the file becomes long and hard to review. Splitting it gives you smaller files, cleaner diffs in pull requests, and a natural place for each team or resource to live.
The usual convention is simple: keep bundle-wide settings in databricks.yml, and put each resource in its own file under resources/.
The include mapping
The top-level include key lists glob patterns. The CLI reads every matching file and merges it into the bundle configuration. Paths are relative to the databricks.yml that contains the include list.
bundle:
name: my_project
include:
- resources/*.yml
- resources/*/*.yml
variables:
catalog:
description: Unity Catalog catalog the job writes to
default: dev_catalogA typical layout looks like this:
my_project/
├── databricks.yml
├── resources/
│ ├── daily_etl.yml
│ └── reporting_pipeline.yml
└── src/
├── ingest.py
└── transform.pyWhat an included file contains
An included file holds configuration keys, most often resources. It does not repeat the bundle mapping. Here is resources/daily_etl.yml:
resources:
jobs:
daily_etl:
name: daily_etl
job_clusters:
- job_cluster_key: main
new_cluster:
spark_version: 15.4.x-scala2.12
node_type_id: ${var.node_type_id}
num_workers: 2
tasks:
- task_key: ingest
job_cluster_key: main
notebook_task:
notebook_path: ../src/ingest.py
base_parameters:
catalog: ${var.catalog}Two details matter here:
- Relative paths inside an included file resolve from that file's own location. That is why the notebook path is
../src/ingest.py, notsrc/ingest.py. - Variables declared in
databricks.ymlare available in included files through${var.name}.
How merging works
The CLI combines all matched files into one tree. Keys that appear in only one file are simply added. If two files define the same resource key, for example two jobs both named daily_etl, the definitions collide and the CLI reports an error or merges them in ways you did not intend. Give every resource a unique key.
You can also override part of a resource per target in databricks.yml. The targets mapping can contain a resources section that changes only the fields you name, so the base definition stays in the included file.
Seeing the result
Before deploying, check what the CLI built. The validate command accepts an output format, which shows the fully merged configuration for a target.
databricks bundle validate -t dev
databricks bundle validate -t dev -o jsonUse the JSON output when you are unsure which file a setting came from or whether a variable resolved as expected.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| A job is missing after deploy | The file does not match any `include` pattern | Check the glob and the file extension |
| Notebook not found | Path written relative to the root instead of the included file | Use a path relative to the included file, such as `../src/ingest.py` |
| Duplicate resource error | Two files use the same resource key | Rename one key |
| Unknown variable | Variable not declared in `databricks.yml` | Add it under `variables` |
Exercise
A bundle has include: [resources/*.yml]. You add a job file at resources/jobs/nightly.yml, and after deploying the job does not appear. Why, and how do you fix it?
Show answer
The pattern resources/*.yml matches only files directly inside resources/, not in subfolders. Add a pattern such as resources/*/*.yml or resources/**/*.yml to include, or move the file up one level. Then run databricks bundle validate to confirm the job is part of the merged configuration.
Exercise
In resources/daily_etl.yml, why is the notebook path ../src/ingest.py and not src/ingest.py?
Show answer
Paths in an included file are resolved relative to that file's location. The file lives in resources/, so .. moves up to the project root before entering src/.