$linuxjunkies
>

declarative configuration

also: declarative, infrastructure as code (IaC) — declarative style

A configuration approach where you describe the desired end state of a system, and the system automatically determines how to achieve it, rather than writing step-by-step instructions.

Declarative configuration specifies what you want the final state to be, not how to get there. Tools like Ansible, Terraform, and NixOS read your declarations and handle the implementation details automatically. This contrasts with imperative approaches that require explicit commands for each step.

For example, instead of writing a shell script that checks if a package is installed, installs it if missing, then configures it line-by-line, you simply declare: "I want nginx version 1.20 installed and running." The tool figures out whether to install, update, or leave it alone.

Benefits include idempotency (safe to run repeatedly), reproducibility across systems, and easier version control. Common declarative tools include docker-compose, Kubernetes YAML manifests, and Terraform HCL.

Related terms