Updated Deployment Guide
This commit is contained in:
parent
de3dc8c841
commit
81bdd402ec
1 changed files with 31 additions and 18 deletions
47
README.md
47
README.md
|
@ -7,38 +7,51 @@ This is the Infrastructure Code for the "Serverraum mit Matratze" shared apartme
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Dependencies](#dependencies)
|
- [Requirements](#requirements)
|
||||||
- [Updating Configuration](#updating-configuration)
|
- [Remote Deployment](#remote-deployment)
|
||||||
- [Hosts](#hosts)
|
- [Hosts](#hosts)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
## Dependencies
|
## Requirements {.tabset .tabset-fade}
|
||||||
|
Requirements to do Remote Deployment using NixOS native Tools.
|
||||||
|
|
||||||
To remotely Deploy Nix-Servers with Native Tools, you will need Access to the nixos-rebuild command.
|
### tab NixOS System (Dev System)
|
||||||
|
|
||||||
You can either use a NixOS System.
|
1. SSH-Access to Target-Host with Sudo Privileges.
|
||||||
|
2. Don't forget to Configure your ssh Config! (See [Hosts](#hosts))
|
||||||
|
3. This Configuration `git clone https://git.kb-one.de/Serverraum-mit-Matratze/infra`
|
||||||
|
|
||||||
Or you can Install the [Nix Package Manager](https://nixos.org/download/) and open a Nix-Shell with the Command available:
|
### tab Non NixOS System with Nix Package Manager (Dev System)
|
||||||
|
|
||||||
|
1. SSH-Access to Target-Host with Sudo Privileges.
|
||||||
|
2. Don't forget to Configure your ssh Config! (See [Hosts](#hosts))
|
||||||
|
3. This Configuration `git clone https://git.kb-one.de/Serverraum-mit-Matratze/infra`
|
||||||
|
4. nixos-rebuild Command `nix-shell -p '(nixos{}).nixos-rebuild'`
|
||||||
|
|
||||||
|
## Remote Deployment
|
||||||
|
|
||||||
|
So, you updated the Configuration on your Computer, how can you deploy it to the Server?
|
||||||
|
|
||||||
|
> Don't forget to stage Added or Deleted Files!
|
||||||
|
> `git add .` (They will be ignored if you miss this step!)
|
||||||
|
|
||||||
|
Now Rebuild the System (on the Server) and Deploy it Remotely to the Server (Example [mow0m](#mow0m)):
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
nix-shell -p '(nixos{}).nixos-rebuild'
|
nixos-rebuild switch --flake .#mow0m --build-host master@mow0m --target-host master@mow0m --use-remote-sudo
|
||||||
```
|
```
|
||||||
|
|
||||||
## Updating Configuration
|
`nixos-rebuild switch` will rebuild a NixOS Configuration and Switch to it immediately, by restarting affected Services.
|
||||||
|
|
||||||
So, you updated the Configuration on your Computer, how can you apply the Updated Config to the Server?
|
`--flake .` specifies the Directory of flake.nix with the NixOS System Configuration.
|
||||||
|
|
||||||
You'll need SSH-Access to the Server, with a User which can run Nix-Commands, and can escalate Privileges using sudo.
|
`#mow0m` tells it to Build the NixOS-System with the Hostname mow0m of the Flake. (See [Hosts](#hosts))
|
||||||
|
|
||||||
1. Don't forget to Configure your ssh Config! (See [Hosts](#hosts))
|
`--build-host master@mow0m` specifies the SSH-Connection to the Build-Host. We will build on the Target Host, to avoid messing with Signatures of the Nix-Store.
|
||||||
2. Stage the Changes if you created or deleted Files `git add .` (They will be ignored if you miss this step!)
|
|
||||||
3. Build and Switch the Config on the Target Server! (Example [mow0m](#mow0m)):
|
|
||||||
|
|
||||||
``` bash
|
`--target-host master@mow0m` specifies the SSH-Connection to the Target-Host to deploy the Configuration to.
|
||||||
nixos-rebuild switch --flake .#mow0m --target-host master@mow0m --build-host master@mow0m --use-remote-sudo
|
|
||||||
```
|
|
||||||
|
|
||||||
You want to keep the Build-Host the Same as the Target-Host, because the Target will only accept Binarys with a trusted Signature. It is way easier, to just run the Build on the Same Machine then.
|
`--use-remote-sudo` this will redirect the Sudo-Prompt on the Target-Host to your Command-Prompt.
|
||||||
|
|
||||||
## Hosts
|
## Hosts
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue