From afdfa6181b9050ce80d76fae97e5194248f97eee Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 19 Jun 2024 13:03:15 +0200 Subject: [PATCH] Inventory: add concrete use-case examples --- inventory/src/machines/machines.cue | 14 +------ inventory/src/services/services.cue | 18 +++++---- inventory/src/tests/1_inventory.json | 58 ---------------------------- inventory/src/tests/borgbackup.json | 38 ++++++++++++++++++ inventory/src/tests/syncthing.json | 45 +++++++++++++++++++++ inventory/src/tests/zerotier.json | 36 +++++++++++++++++ 6 files changed, 130 insertions(+), 79 deletions(-) delete mode 100644 inventory/src/tests/1_inventory.json create mode 100644 inventory/src/tests/borgbackup.json create mode 100644 inventory/src/tests/syncthing.json create mode 100644 inventory/src/tests/zerotier.json diff --git a/inventory/src/machines/machines.cue b/inventory/src/machines/machines.cue index cdbeed5f..a917e1e9 100644 --- a/inventory/src/machines/machines.cue +++ b/inventory/src/machines/machines.cue @@ -1,20 +1,8 @@ package machines -#ServiceRole: "server" | "client" | "both" #machine: machines: [string]: { name: string, description?: string, - icon?: string, - // each machines service - services?: [string]: { - // Roles if specificed must contain one or more roles - // If no roles are specified, the service module defines the default roles. - roles?: [ ...#ServiceRole ], - // The service config to use - // This config is scoped to the service.module, only serializable data (strings,numbers, etc) can be assigned here - config: { - ... - } - } + icon?: string } \ No newline at end of file diff --git a/inventory/src/services/services.cue b/inventory/src/services/services.cue index b95e117f..6949c81b 100644 --- a/inventory/src/services/services.cue +++ b/inventory/src/services/services.cue @@ -1,5 +1,7 @@ package services +#ServiceRole: "server" | "client" | "both" + #service: services: [string]: { // Required meta fields meta: { @@ -12,14 +14,14 @@ package services // We moved the machine sepcific config to "machines". // It may be moved back depending on what makes more sense in the future. - // machineConfig: { - // [string]: { - // roles: string[], - // config: { - // defaultUser?: string - // } - // } - // }, + machineConfig: { + [string]: { + roles?: [ ...#ServiceRole ], + config?: { + ... + } + } + }, // Configuration for the service config: { diff --git a/inventory/src/tests/1_inventory.json b/inventory/src/tests/1_inventory.json deleted file mode 100644 index 58347d2d..00000000 --- a/inventory/src/tests/1_inventory.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "machines": { - "jon_machine": { - "name": "jon", - "description": "Jon's machine", - "icon": "assets/icon.png", - "services": { - "matrix": { - "roles": ["server"] - } - } - }, - "anna_machine": { - "name": "anna", - "description": "anna's machine" - } - }, - "meta": { - "name": "clan name" - }, - "services": { - "sync-home": { - "meta": { - "name": "My Home Sync" - }, - "module": "syncthing", - "config": { - "folders": ["/sync/my_f"] - } - }, - "matrix": { - "meta": { - "name": "Our matrix chat", - "description": "Matrix chat service for our clan" - }, - "module": "matrix-synapse", - "config": { - "compression": "zstd" - } - }, - "backup": { - "meta": { - "name": "My daily backup" - }, - "module": "borgbackup", - "config": {} - }, - "borgbackup_1": { - "meta": { - "name": "My weekly backup" - }, - "module": "borgbackup", - "config": { - "compression": "lz4" - } - } - } -} diff --git a/inventory/src/tests/borgbackup.json b/inventory/src/tests/borgbackup.json new file mode 100644 index 00000000..43e04322 --- /dev/null +++ b/inventory/src/tests/borgbackup.json @@ -0,0 +1,38 @@ +{ + "machines": { + "camina_machine": { + "name": "camina" + }, + "vyr_machine": { + "name": "vyr" + }, + "vi_machine": { + "name": "vi" + } + }, + "meta": { + "name": "kenjis clan" + }, + "services": { + "backup": { + "meta": { + "name": "My backup" + }, + "module": "borbackup-static", + "machineConfig": { + "vyr": { + "roles": ["server"] + }, + "vi": { + "roles": ["client"] + }, + "camina_machine": { + "roles": ["client"] + } + }, + "config": { + "folders": ["/home", "/root", "/var", "/etc"] + } + } + } +} diff --git a/inventory/src/tests/syncthing.json b/inventory/src/tests/syncthing.json new file mode 100644 index 00000000..1f5d59cf --- /dev/null +++ b/inventory/src/tests/syncthing.json @@ -0,0 +1,45 @@ +{ + "machines": { + "camina_machine": { + "name": "camina" + }, + "vyr": { + "name": "vyr" + }, + "vi": { + "name": "vi" + } + }, + "meta": { + "name": "kenjis clan" + }, + "services": { + "sync_files": { + "meta": { + "name": "My sync" + }, + "module": "syncthing-static-peers", + "machineConfig": { + "vyr": {}, + "vi": {}, + "camina_machine": {} + }, + "config": { + "folders": { + "test": { + "path": "~/data/docs", + "devices": ["camina", "vyr", "vi"] + }, + "videos": { + "path": "~/data/videos", + "devices": ["camina", "vyr", "ezra"] + }, + "playlist": { + "path": "~/data/playlist", + "devices": ["camina", "vyr", "ezra"] + } + } + } + } + } +} diff --git a/inventory/src/tests/zerotier.json b/inventory/src/tests/zerotier.json new file mode 100644 index 00000000..21a2b097 --- /dev/null +++ b/inventory/src/tests/zerotier.json @@ -0,0 +1,36 @@ +{ + "machines": { + "camina_machine": { + "name": "camina" + }, + "vyr_machine": { + "name": "vyr" + }, + "vi_machine": { + "name": "vi" + } + }, + "meta": { + "name": "kenjis clan" + }, + "services": { + "backup": { + "meta": { + "name": "My backup" + }, + "module": "borbackup-static", + "machineConfig": { + "vyr_machine": { + "roles": ["server"] + }, + "vi_machine": { + "roles": ["peer"] + }, + "camina_machine": { + "roles": ["peer"] + } + }, + "config": {} + } + } +}