[refactor] moving cubes into own package"
Publish snapshot / snapshot (push) Successful in 1m2s

[fix] default parameter run records parameters in session for replay[fix] remove default parameters for several cubes
This commit is contained in:
Benjamin Diedrichsen
2026-07-28 12:18:10 +02:00
parent ac050c4459
commit 6ecb2c366f
130 changed files with 3386 additions and 520 deletions
@@ -0,0 +1,76 @@
# cockpit
**Install Cockpit web-based server management interface**
## Purpose
This cube installs Cockpit, a powerful web-based interface for managing Linux servers, making system administration accessible through your browser.
## What is Cockpit?
Cockpit is a modern, interactive server admin interface that runs in your web browser. It provides:
- **Real-time monitoring**: CPU, memory, disk, and network usage graphs
- **Container management**: View and manage Docker containers
- **Service management**: Start, stop, and manage systemd services
- **Storage administration**: Manage disks, RAID, and filesystems
- **Network configuration**: Configure network interfaces and firewall
- **Terminal access**: Built-in terminal for command-line access
- **User management**: Create and manage user accounts
- **Software updates**: View and apply system updates
Think of it as a control panel for your Linux server - all accessible from any web browser.
## What This Cube Does
1. Installs the `cockpit` package
2. Installs `sscg` (Simple Signed Certificate Generator) for HTTPS support
3. Starts the Cockpit service
4. Makes Cockpit accessible on port 9090
## Configuration
This cube currently has no configurable parameters.
## Dependencies
None - this cube can run standalone.
## Post-Installation
Access Cockpit by navigating to:
```
https://your-server-ip:9090
```
Login with any valid system user account (e.g., root or a user created with the `user-add` cube).
### Security Notes
- Cockpit uses HTTPS by default (self-signed certificate)
- Your browser will show a security warning on first access (expected with self-signed certs)
- Consider using UFW to restrict access: `sudo ufw allow from YOUR_IP to any port 9090`
- Disable Cockpit when not in use: `sudo systemctl stop cockpit.socket`
## Common Use Cases
- Monitor server performance in real-time
- Manage Docker containers without command-line
- View system logs and troubleshoot issues
- Configure network settings
- Apply system updates
- Manage storage and filesystems
## Managing Cockpit
Start/stop Cockpit:
```bash
sudo systemctl start cockpit.socket
sudo systemctl stop cockpit.socket
sudo systemctl status cockpit.socket
```
Disable Cockpit from starting on boot:
```bash
sudo systemctl disable cockpit.socket
```
@@ -0,0 +1,13 @@
from pyinfra import host
from pyinfra.operations import server, apt
apt.packages(
packages=[ "sscg cockpit"],
present=True,
_sudo=True
)
server.service(
'cockpit',
running=True,
)
@@ -0,0 +1,7 @@
import { Manifest } from '@bitsquare/nopy-cube';
export default Manifest({
id: 'admin:cockpit',
name: 'Install cockpit and utils',
dependencies: () => [],
});
@@ -0,0 +1,34 @@
from pyinfra import host
from pyinfra.operations import server, files
"""
Deployment script for the admin:hostname cube.
Uses pyinfra's server.hostname operation to set and persist the system hostname.
"""
HOSTNAME = host.data.HOSTNAME
if HOSTNAME:
server.hostname(
name=f"Set system hostname to {HOSTNAME}",
hostname=HOSTNAME,
_sudo=True,
)
# 2. Update /etc/hosts to prevent "unable to resolve host" errors
# This looks for the line starting with 127.0.1.1 and replaces it entirely
files.line(
name="Update /etc/hosts for local resolution",
path="/etc/hosts",
line=r"^127\.0\.1\.1\s+.*",
replace=f"127.0.1.1 {HOSTNAME}",
_sudo=True,
)
# 3. Restart Avahi (Network Broadcast)
# This pushes the name change out to the shared network
server.service(
name="Restart Avahi to broadcast new mDNS name",
service="avahi-daemon",
restarted=True,
_sudo=True,
)
@@ -0,0 +1,20 @@
import { Manifest, uniqid } from '@bitsquare/nopy-cube';
import { z } from 'zod';
/**
* Manifest for the admin:hostname cube.
* This cube allows for setting and persistently changing the system's hostname.
*/
export default Manifest({
id: 'admin:hostname',
name: 'Permanently change the hostname',
dependencies: () => [],
schema: z.object({
HOSTNAME: z
.string()
.min(1)
.max(64)
.describe('The new hostname for the target host')
.default(`host-${uniqid()}`),
}),
});
@@ -0,0 +1,23 @@
# Cube: admin/locale
Configures system keyboard layout permanently by updating `/etc/default/keyboard` and using `localectl`.
## Configuration
- `LAYOUT` (string): Keyboard layout (e.g. "ch", "us", "de"). Default: "ch".
- `MODEL` (string): Keyboard model. Default: "pc105".
- `VARIANT` (string): Keyboard variant. Default: "".
- `OPTIONS` (string): Keyboard options (comma separated). Default: "".
## Usage
```javascript
import { Manifest } from '@bitsquare/nopy-cube';
export default Manifest({
name: 'My Host Setup',
dependencies: () => [
['admin:locale', { LAYOUT: 'de' }]
]
});
```
@@ -0,0 +1,55 @@
from pyinfra import host
from pyinfra.operations import server, files
LAYOUT = host.data.LAYOUT
MODEL = host.data.MODEL
VARIANT = host.data.VARIANT
OPTIONS = host.data.OPTIONS
# Update /etc/default/keyboard
files.line(
name="Update XKBMODEL in /etc/default/keyboard",
path="/etc/default/keyboard",
line=r'^XKBMODEL=.*',
replace=f'XKBMODEL="{MODEL}"',
_sudo=True,
)
files.line(
name="Update XKBLAYOUT in /etc/default/keyboard",
path="/etc/default/keyboard",
line=r'^XKBLAYOUT=.*',
replace=f'XKBLAYOUT="{LAYOUT}"',
_sudo=True,
)
files.line(
name="Update XKBVARIANT in /etc/default/keyboard",
path="/etc/default/keyboard",
line=r'^XKBVARIANT=.*',
replace=f'XKBVARIANT="{VARIANT}"',
_sudo=True,
)
files.line(
name="Update XKBOPTIONS in /etc/default/keyboard",
path="/etc/default/keyboard",
line=r'^XKBOPTIONS=.*',
replace=f'XKBOPTIONS="{OPTIONS}"',
_sudo=True,
)
# Apply keyboard configuration
server.shell(
name="Apply keyboard setup",
commands=["setupcon", "service keyboard-setup restart"],
_sudo=True,
)
# Set X11 keyboard layout using localectl if available
server.shell(
name="Set X11 keyboard layout using localectl",
commands=[f"localectl set-x11-keymap {LAYOUT} {MODEL} '{VARIANT}' '{OPTIONS}'"],
_sudo=True,
_ignore_errors=True,
)
@@ -0,0 +1,14 @@
import { Manifest } from '@bitsquare/nopy-cube';
import { z } from 'zod';
export default Manifest({
id: 'admin:locale',
name: 'Configure system locale and keyboard layout',
dependencies: () => [],
schema: z.object({
LAYOUT: z.string().describe('Keyboard layout (e.g. "ch", "us", "de")').default('ch'),
MODEL: z.string().describe('Keyboard model').default('pc105'),
VARIANT: z.string().describe('Keyboard variant').default(''),
OPTIONS: z.string().describe('Keyboard options (comma separated)').default(''),
}),
});