Set up CUE repository¶
syslet consumes JSON, which is a machine format: writing it by hand means repeating the same fields in every spec and fighting braces, quotes and commas. CUE adds defaults, comments and validation against a schema, removes the duplication, and still produces the JSON syslet reads.
In this tutorial, you'll set up a git repository that describes a host in CUE instead of raw JSON, and connect it to the host with cue cmd plan and cue cmd apply.
The following tutorials deploy into it.
Prerequisites¶
- An empty server with syslet installed, as in Installation.
This tutorial calls it
web01.example.com. - CUE v0.16 or newer on your workstation.
- SSH public-key auth to the server as root.
The commands below run
ssh <host> syslet; if you log in as another user, addsudoto thecmdlists insyslet_tool.cue.
1. Create the repository¶
2. Add the base config¶
Create syslet.cue:
sysdef is where you describe the host: containers, networks, volumes, builds and secrets, each keyed by name.
sysletcore.#Sysdef on its own is only the schema: it defines which fields exist and requires you to set each of them.
Several of those fields take the same value almost every time, so sysletcore.#SysdefDefaults fills in enabled: true, removalAllowed: true, desiredState: "running" and reclaimPolicy: "Delete" unless you set them, and you don't have to repeat them in every entry.
3. Add the plan and apply commands¶
Create syslet_tool.cue.
Both commands feed syslet.specRendered to syslet --stdin over SSH.
plan runs it with --diff, and apply shows the same diff, asks for confirmation, then runs syslet for real:
These two files are a starting point; adapt them to your setup.
4. Check the setup¶
Add the syslet schema to cue.mod/module.cue, pinned to the latest v0 release:
| Bash | |
|---|---|
Check that it evaluates:
| Bash | |
|---|---|
This prints [], since nothing is defined yet.
Now check the connection to the host:
| Bash | |
|---|---|
On an empty server, syslet finds nothing to do:
| Text Only | |
|---|---|
Commit the setup:
| Bash | |
|---|---|
The repository is ready. Continue with Deploy with CUE.