btrbk
btrbk copied to clipboard
Add configuration templates (resusable snippets)
I discovered the group
directive in the docs the other day, and while quite powerful, most of the things I thought it would let me do that I couldn't before are still not possible because there's no way to associate configuration with a group.
I suggest adding a group_config
directive that can only be used at the top level of a config file, after which other config directives can appear until e.g. the next volume
directive. It occurs to me that the "group" keyword could also be reused for this since it's currently ignored at the top level (I just tried it).
When the group
directive is used, its associated configuration would be inherited by the vol/subvol/target currently being described, with the group's config overriding any options previously defined in the vol/subvol/target. This allows the user total control over how the configs are combined by carefully selecting where the group
directives appear.
The only sticking point I can see is the issue that certain config directives aren't allowed in certain contexts. I strongly suspect that it would be better to issue an error when a group directive implies configuration inappropriate to the current context, but ignoring it would also be an option.
Sounds reasonable. I have some similar changes in mind regarding the config, e.g. "target templates" specifying a host along with retention policy.
I think a better wording for what you are suggesting would be a new template
section (to be defined in global context), which could be applied in every other contexts.
something like this:
template not-so-important
target_preserve_min no
target_preserve 30d
template keep-forever
target_preserve 30d *m
target ssh://somewhere
apply_template not-so-important
As you said it might make sense to combine with group
directive, it would then look like this:
target ssh://somewhere
group not-so-important
That makes sense. Do you see any difference between our two ideas other than the directive name? Does your templates idea still incorporate the idea of ordering-based setting overrides? What's your vision of what should happen when a line of template config doesn't apply to the current config?