| 1 |
# Group hosts in config and meta profiles |
| 2 |
|
| 3 |
Let's consider the situation where you have multiple hosts from different distros and you |
| 4 |
want an easy way to structure your config file nicely but also simplify the use |
| 5 |
of templates (since multiple hosts in the same distro would share the same configs parts - |
| 6 |
or if branch in templates). |
| 7 |
|
| 8 |
You define two types of profiles: |
| 9 |
|
| 10 |
* **Meta profiles**: for example for distros it would be something like `os_arch`, `os_debian` and so on. |
| 11 |
These are never directly used for installing dotfiles but instead included by other profiles. |
| 12 |
* **Host profiles** (defaults to hostnames): the usual `home`, `office`, etc |
| 13 |
|
| 14 |
Each *Host profile* would include a *meta profile* and inherit all its dotfiles as well as |
| 15 |
it variables. For example in the *meta profile* you would define variables like `distro: debian` |
| 16 |
that you could use in your templates with `{%@@ if distro == "debian" @@%}` to target all |
| 17 |
profiles that inherit from the same *meta profile*. |
| 18 |
|
| 19 |
```yaml |
| 20 |
profiles: |
| 21 |
meta_base: |
| 22 |
dotfiles: |
| 23 |
- f_zshrc |
| 24 |
- f_zshrc |
| 25 |
os_arch: |
| 26 |
variables: |
| 27 |
distro: arch |
| 28 |
include: |
| 29 |
- meta-base |
| 30 |
os_debian: |
| 31 |
variables: |
| 32 |
distro: debian |
| 33 |
include: |
| 34 |
- meta-base |
| 35 |
home: |
| 36 |
include: |
| 37 |
- os_arch |
| 38 |
dotfiles: |
| 39 |
- f_vimrc |
| 40 |
office: |
| 41 |
include: |
| 42 |
- os_debian |
| 43 |
dotfiles: |
| 44 |
- f_something |
| 45 |
``` |
| 46 |
|
| 47 |
You then have the opportunity in your templates to do the following |
| 48 |
that would select the if branch for all profiles inheriting from |
| 49 |
a specific *meta profile*. |
| 50 |
``` |
| 51 |
# zsh-syntax-highlighting |
| 52 |
# https://github.com/zsh-users/zsh-syntax-highlighting |
| 53 |
{%@@ if distro == "arch" @@%} |
| 54 |
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
| 55 |
{%@@ elif distro == "debian" @@%} |
| 56 |
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
| 57 |
{%@@ endif @@%} |
| 58 |
``` |