Includes
The configuration may be split into multiple files by adding includes = "glob-pattern"
to the main configuration file.
E.g. the following profiles.conf
loads configurations from conf.d
and profiles.d
:
version = "1"
# Includes
includes = ["conf.d/*.conf", "profiles.d/*.yaml", "profiles.d/*.toml"]
# Defaults
[global]
initialize = true
version: "1"
includes:
- "conf.d/*.conf"
- "profiles.d/*.yaml"
- "profiles.d/*.toml"
global:
initialize: true
includes = ["conf.d/*.conf", "profiles.d/*.yaml", "profiles.d/*.toml"]
global {
initialize = true
}
{
"version": "1",
"includes": [
"conf.d/*.conf",
"profiles.d/*.yaml",
"profiles.d/*.toml"
],
"global": {
"initialize": true
}
}
Included configuration files may use any supported format and settings are merged so that multiple files can extend the same profiles. The HCL format is special in that it cannot be mixed with other formats.
Within included files, the current configuration path is not changed. Path resolution remains relative to the path of the main configuration file.
Included files cannot include nested files. Specifying includes
inside an included file has no effect.
Configuration Merging
Loading a configuration file involves loading the physical file from disk and applying all variables and templates prior to parsing the file in a supported format hcl
, json
, toml
and yaml
. This means variables and templates must create valid configuration markup that can be parsed or loading will fail.
Configuration files are loaded and applied in a fixed order:
- The main configuration file is loaded first
includes
are iterated in declaration order:- Every item may be a single file path or glob expression
- Glob expressions are resolved and iterated in alphabetical order
- All paths are resolved relative to configuration path
Configuration files are loaded in the following order when assuming /etc/resticprofile/profiles.conf
with includes = ["first.conf", "conf.d/*.conf", "last.conf"]
:
/etc/resticprofile/profiles.conf
/etc/resticprofile/first.conf
/etc/resticprofile/conf.d/00_a.conf
/etc/resticprofile/conf.d/01_a.conf
/etc/resticprofile/conf.d/01_b.conf
/etc/resticprofile/last.conf
Configuration merging follows the logic:
- Configuration properties are replaced
- Configuration structure (tree) is merged
- What includes later overrides what defines earlier
- Lists of values or lists of objects are considered properties not config structure and will be replaced
version: "1"
includes:
- first.yaml
- second.yaml
default:
backup:
source:
- /usr
version: "1"
default:
initialize: false
backup:
source:
- /etc
- /opt
version: "1"
default:
initialize: true
backup:
exclude:
- .*
version: "1"
includes:
- first.yaml
- second.yaml
default:
initialize: true
backup:
exclude:
- .*
source:
- /etc
- /opt
You can use resticprofile [<profile-name>.]show
(or resticprofile [--name <profile-name>] show
) to see the resulting configuration after merging.
resticprofile
prior to v0.18.0 had a slightly different behaviour when merging configuration properties of a different type (e.g. number <-> text or list <-> single value). In such cases the existing value was not overridden by an included file, breaking the rule “what includes later overrides what defines earlier”.