From 9e9603499788dd3de921d95f6d1d9f30feb291b5 Mon Sep 17 00:00:00 2001 From: June Date: Sat, 8 Jun 2024 21:14:53 +0200 Subject: [PATCH 1/2] docs: document basic usage of infra-rebuild --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 1421686..5643d47 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,23 @@ # infra-rebuild +infra-rebuild mirrors nixos-rebuild closely in its command-line interface, but focuses on making infrastructure deployment more convenient. It is built for infrastructure defined in a flake, where each hosts configuration is represented by a different `nixosConfiguration` in the flakes output. + +For building the configuration of e.g. two hosts called `web-01` and `git` one can simply run: + +``` +infra-rebuild build web-01 git +``` + +For deploying the hosts - using the switch operation - it's as simple as: + +``` +infra-rebuild switch web-01 git +``` + +Here infra-rebuild will simply run `nixos-rebuild switch` with the `target-host` option set for each host. +Because infra-rebuild tries to be usable without any configuration, by default it queries the hosts FQDN from its `nixosConfiguration` and uses that for the target host. +However to override aspects of the target host for specific or all hosts, infra-rebuild also accepts a `deployment_configuration.json` as configuration. + ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. From 8845a6b4087a418b80f46637bd740396e092e319 Mon Sep 17 00:00:00 2001 From: June Date: Sat, 8 Jun 2024 21:34:12 +0200 Subject: [PATCH 2/2] docs: document configuration --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 5643d47..c1faf59 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,53 @@ Here infra-rebuild will simply run `nixos-rebuild switch` with the `target-host` Because infra-rebuild tries to be usable without any configuration, by default it queries the hosts FQDN from its `nixosConfiguration` and uses that for the target host. However to override aspects of the target host for specific or all hosts, infra-rebuild also accepts a `deployment_configuration.json` as configuration. +## Configuration + +infra-rebuild accepts optional configuration in a `deployment_configuration.json`. \ +The following keys are available to be set for configuring various aspects of deployment for specific or all hosts: + +- `default.targetPort`: A default port to use for connecting to all host. +- `default.targetUser`: A default user to use for connecting to all host. +- `hosts..targetPort`: The port to use for connecting to ``. +- `hosts..targetUser`: The user to use for connecting to ``. +- `hosts..targetHostname`: The hostname to use for connecting to ``. + +### Example + +An example `deployment_configuration.json` might look like this then: + +```json +{ + "default": { + "targetPort": 2222, + "targetUser": "deploy" + }, + "hosts": { + "web-01": { + "targetUser": "web-deploy", + "targetHostname": "web-01-intern.infra.example", + "targetPort": 22 + } + }, + "git": { + "targetUser": "git-deploy" + } +} +``` + +### Order of Precedence + +The order of precedence from least to greatest for `targetPort` and `targetUser` is the following: + +1. system default +2. `default.targetPort/User` +3. `hosts..targetPort/User` + +The order of precedence from least to greatest for `targetHostname` is the following: + +1. FQDN from hosts nixosConfiguration +2. `hosts..targetHostname` + ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.