Skip to content

Plan Includes

Plans can include other plan files using the include directive, enabling modular and reusable infrastructure definitions.

plan "full-setup" {
step "Base packages" {
package "curl" state="present"
package "vim" state="present"
}
include "common/security.kdl"
include "common/monitoring.kdl"
step "Deploy app" {
shell "/opt/deploy.sh"
}
}

Include paths are resolved relative to the directory of the including plan file. Given this file structure:

plans/
├── main.kdl
└── common/
├── security.kdl
└── monitoring.kdl

The include "common/security.kdl" in main.kdl resolves to plans/common/security.kdl.

Every relative path inside an included plan — its own includes, its vars-files, and file sources — resolves from that plan’s directory, so a reusable plan can keep its files beside it:

plans/
├── main.kdl
└── roles/web/
├── plan.kdl
├── defaults.kdl
└── nginx.conf
plans/main.kdl
plan "main" {
include "roles/web/plan.kdl"
}
plans/roles/web/plan.kdl
plan "web" {
vars-file "defaults.kdl" // → plans/roles/web/defaults.kdl
step "Configure nginx" {
file "/etc/nginx/nginx.conf" src="nginx.conf" template=#true
// src → plans/roles/web/nginx.conf
}
}

Included plan steps are inlined at parse time. The include directive is replaced with the steps from the included plan. The result is a flat sequence of steps, as if they were written directly in the parent plan.

Included plans can define their own vars block and vars-files. These are merged into the parent plan’s variables, with the parent’s values taking precedence on conflicts. The merged variables are visible to every step, not only the included plan’s own.

When two plans included side by side define the same variable, the one included first wins; within an included plan, inline vars win over its vars-files, as they do at the top level.

common/security.kdl
plan "security" {
vars {
ssh-port 22
fail2ban-maxretry 5
}
step "Install fail2ban" {
package "fail2ban" state="present"
}
}

If the parent plan also defines ssh-port, the parent’s value wins.

tags="a,b" on an include adds those tags to every step the included plan brings in, including the steps of plans it includes in turn. Each step keeps its own tags first, followed by the include’s, then those of any include further out; a tag appears once.

main.kdl
plan "main" {
include "common/security.kdl" tags="security"
}
common/security.kdl
plan "security" {
step "Install fail2ban" tags="packages" { // tags: packages, security
package "fail2ban" state="present"
}
include "ssh.kdl" tags="ssh" // its steps: ..., ssh, security
}

glidesh run --tags security then runs every step of security.kdl and ssh.kdl, without tagging each one. tags is the only attribute an include takes; any other is an error.

glidesh detects circular includes and reports an error. If a.kdl includes b.kdl and b.kdl includes a.kdl, the parser will fail with a clear error message.