feat(templates): LXC container and chained web server notebooks (#11)

infra/lxc-container.md creates an unprivileged container on a Proxmox
host with ShellBook's key, waits for its address and adds it to Hosts.
services/web-server.md installs nginx on an existing host or on a new
container through ::use. Document chaining in the spec (3.6) and in the
workspace format guide.
This commit is contained in:
Florian Schmidt
2026-11-16 11:42:12 +01:00
parent 845d6c828e
commit 85afd105f7
4 changed files with 212 additions and 1 deletions
@@ -0,0 +1,50 @@
---
title: Install a web server (nginx)
params:
target: { type: choice, options: [lxc, existing], default: lxc, label: Install on }
server_name: { type: name, required: true, default: web, label: Server name }
host: { type: host, required: true, default: "{{ct.host}}", label: Target server }
---
# Install nginx on {{host}}
Example of a chained notebook. Choose **Install on: lxc** to create a fresh Proxmox
container first (its form appears below), or **existing** to pick a server from
Hosts. The install steps then target **Target server**, which defaults to the new
container once it is in Hosts.
:::when{target=lxc}
## New container
::use{notebook="infra/lxc-container.md" as=ct with="hostname={{server_name}}"}
:::
## Install
Runs as root, or through passwordless `sudo -n` for other users.
```sh {check host="{{host}}" id=apt title="Debian/Ubuntu with apt and systemd"}
command -v apt-get
command -v systemctl
```
```sh {check host="{{host}}" id=installed title="nginx is installed"}
dpkg-query -W -f='${Status}\n' nginx | grep -qx 'install ok installed'
```
```sh {run host="{{host}}" id=install title="Install and start nginx" confirm timeout=600}
if [ "$(id -u)" -eq 0 ]; then as_root=""; else as_root="sudo -n"; fi
$as_root apt-get update
$as_root env DEBIAN_FRONTEND=noninteractive apt-get install -y nginx
$as_root systemctl enable --now nginx
```
```sh {check host="{{host}}" id=active title="nginx is running and answers"}
systemctl is-active nginx
timeout 5 bash -c 'exec 3<>/dev/tcp/127.0.0.1/80'
```
:::after{step=install}
nginx is installed on **{{host}}**. Put your site into `/etc/nginx/sites-available/`
and review the firewall before exposing it.
:::