feat: Use mise tasks to ease list/install/update/diff of LXC profiles between LXC and the repo

This commit is contained in:
xavier committed 2026-11-20 23:40:55 +01:00
1 parent d21bb31d95
commit eff9cfc92c
17 files changed
+359 -81

No files matched your search

+22 -16
View File
@@ -7,28 +7,34 @@ This repository contains a collection of LXD profiles and network configurations
- `profiles/`: Contains various LXD profile definitions categorized by their purpose (e.g., applications, networking, storage).
- `network/`: Defines LXD network configurations.
- `docs/`: Additional documentation and helper scripts.
- `install.bash`: A utility script to manage LXD profiles.
- `mise.toml`, `.mise/`: [mise](https://mise.jdx.dev) tasks to manage LXD profiles.
## Usage
### `install.bash`
Prerequisites: [mise](https://mise.jdx.dev) and the `lxc` client. mise installs the
other tools declared in `mise.toml` (`yq`, `gum`, `delta`) with `mise install`.
This script allows you to create and update LXD profiles based on the YAML files in the `profiles/` directory.
A short help message is displayed when entering the directory (mise `enter` hook),
and `mise tasks` lists all available tasks.
#### Update all profiles
A profile can be designated by its name (`docker`) or its file
(`profiles/containerization/docker.profile.yaml`).
To update all profiles defined in this repository, run the script without any arguments:
| Task | Description |
|---|---|
| `mise run list [--all]` | Repository profiles and their state in LXD: ✅ up to date, ⚠️ installed but different, ⬜ not installed. `--all` also shows 🔹 profiles installed in LXD but missing from the repository |
| `mise run diff [profile...]` | Diff between the installed profile (LXD) and the repository file. Without argument, every installed profile that differs. `--exit-code` returns 1 when there are differences |
| `mise run install [profile...]` | Creates or updates profiles. An existing profile that differs shows its diff and asks for confirmation (`--yes` to skip). Without argument, interactive selection; `--all` for every profile |
| `mise run import [profile] [file]` | Writes an installed LXD profile to the repository (without `used_by`, `project`, empty `config`/`devices`). Defaults to the repository file declaring that name, or `profiles/<profile>.profile.yaml`. Review with `git diff` before committing |
Differences are computed on a normalized form (keys sorted, values as strings,
read-only fields dropped), so formatting or quoting alone never shows up as a
change. Top-level keys unknown to LXD (silently ignored by `lxc profile edit`)
are reported, and `install` refuses such files.
```bash
./install.bash
mise run list --all
mise run diff docker
mise run install docker profiles/applications/traefik.profile.yaml
mise run import s3 profiles/applications/s3.profile.yaml && git diff
```
#### Update specific profiles
To update one or more specific profiles, provide their file paths as arguments to the script:
```bash
./install.bash profiles/containerization/docker.profile.yaml profiles/applications/traefik.profile.yaml
```
This will update only the `docker` and `traefik` profiles.