infra/README.md

99 lines
3.1 KiB
Markdown

# Serverraum-mit-Matratze Infrastructure
[![license](https://img.shields.io/badge/license-GPL%20v2-blue)](LICENSE)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
This is the Infrastructure Code for the "Serverraum mit Matratze" shared apartment.
## Table of Contents
- [Requirements](#requirements)
- [Remote Deployment](#remote-deployment)
- [Hosts](#hosts)
- [License](#license)
## Requirements
Requirements to do Remote Deployment using NixOS native Tools.
### NixOS System (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`
### 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. Open Nix-Shell with nixos-rebuild Command available `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
nixos-rebuild switch --flake .#mow0m --build-host master@mow0m --target-host master@mow0m --use-remote-sudo
```
`nixos-rebuild switch` will rebuild a NixOS Configuration and Switch to it immediately, by restarting affected Services.
`--flake .` specifies the Directory of flake.nix with the NixOS System Configuration.
`#mow0m` tells it to Build the NixOS-System with the Hostname mow0m of the Flake. (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.
`--target-host master@mow0m` specifies the SSH-Connection to the Target-Host to deploy the Configuration to.
`--use-remote-sudo` this will redirect the Sudo-Prompt on the Target-Host to your Command-Prompt.
## Hosts
### mow0m
[Configuration](./systems/x86_64-linux/mow0m)
<table>
<tr>
<td>User</td>
<td>master@mow0m</td>
</tr>
<tr>
<td>Cpu</td>
<td>Intel(R) Core(TM) i5-6400 (4) @ 3.30 GHz</td>
</tr>
<tr>
<td>Ram</td>
<td>32GB</td>
</tr>
<tr>
<td>Build</td>
<td><pre lang="bash">nixos-rebuild switch --flake .#mow0m --target-host master@mow0m --build-host master@mow0m --use-remote-sudo</pre></td>
</tr>
<tr>
<td>SSH Config</td>
<td><pre lang="bash">
Host mow0m
HostName mow0m.lan
User master
Port 9553
IdentityFile ~/.ssh/master@mow0m
Host remoteunlock-mow0m
HostName mow0m.lan
User root
Port 2550
IdentityFile ~/.ssh/remoteunlock-mow0m</pre></td>
</tr>
</table>
## License
[GPL v2](../LICENSE)