1
0
Files
pve-lab/cluster-info.sh

70 lines
2.7 KiB
Bash
Raw Permalink Normal View History

2026-08-02 10:40:47 -05:00
#!/usr/bin/env bash
# Generate CLUSTER-INFO.md: a concise, current description of the running lab
# (node IPs, credentials, shared storage, live status) for humans and future LLM
# agents that need to operate against this cluster.
# NOTE: contains the root password, so the output is gitignored — do not commit.
set -uo pipefail
source "$(dirname "$0")/lab.env"
OUT="${SCRIPT_DIR}/CLUSTER-INFO.md"
# pull live info from pve1; empty if unreachable
p1() { lab_ssh "$PVE1_IP" "$*" 2>/dev/null; }
pvecm_nodes="$(p1 pvecm nodes)"
pvecm_status="$(p1 pvecm status)"
pvesm_status="$(p1 pvesm status)"
pve_version="$(p1 pveversion)"
fp="<key not found>"; [[ -f "$SSH_PUB" ]] && fp="$(ssh-keygen -lf "$SSH_PUB" 2>/dev/null)"
{
cat <<EOF
# Local Proxmox VE Test Cluster — CLUSTER-INFO
> Auto-generated by \`cluster-info.sh\` on $(date -Is).
> **Contains the root password. Gitignored — do not commit or share.**
Disposable, nested (libvirt/KVM) Proxmox VE lab on a Fedora workstation, used to
test software that drives a Proxmox cluster. Managed by the scripts in this
\`pve-lab/\` directory (see \`README.md\`).
## Nodes
| Role | Name | IP | Web UI |
|------|------|----|--------|
| PVE node 1 | ${PVE1_NAME} | ${PVE1_IP} | https://${PVE1_IP}:8006 |
| PVE node 2 | ${PVE2_NAME} | ${PVE2_IP} | https://${PVE2_IP}:8006 |
| Storage (NFS + iSCSI) | ${STORE_NAME} | ${STORE_IP} | (Debian; no web UI) |
Cluster: **${CLUSTER_NAME}** · Domain: **${DOMAIN}** · Network: ${NET_SUBNET}/${NET_PREFIX} (gw ${NET_GW})
## Credentials
- **Root password** (all PVE nodes + storage VM): \`${ROOT_PASSWORD}\`
- **SSH key** (passwordless root everywhere): \`${SSH_KEY}\`
- Fingerprint: ${fp}
- SSH from this host — \`IdentitiesOnly=yes\` is **required** (otherwise the agent's
keys exhaust the server's MaxAuthTries before the lab key is offered):
\`\`\`bash
ssh -i ${SSH_KEY} -o IdentitiesOnly=yes root@${PVE1_IP}
# or, from pve-lab/: source lab.env && lab_ssh ${PVE1_IP} pvecm status
\`\`\`
## Shared storage (visible on both nodes)
- **lab-nfs** — NFS from \`${STORE_IP}:/srv/nfs\` (content: images, iso, vztmpl, backup, rootdir)
- **lab-lvm** — shared LVM volume group \`pve_shared\` on the iSCSI LUN
- Storage VM iSCSI target: \`${ISCSI_IQN}\` (portal ${STORE_IP}:3260)
## Live status
EOF
if [[ -n "$pvecm_nodes" ]]; then
printf '### pvecm nodes\n```\n%s\n```\n' "$pvecm_nodes"
printf '### pvecm status\n```\n%s\n```\n' "$pvecm_status"
printf '### pvesm status\n```\n%s\n```\n' "$pvesm_status"
[[ -n "$pve_version" ]] && printf '### pveversion\n```\n%s\n```\n' "$pve_version"
else
echo "_Cluster not reachable over SSH when this file was generated; static config above still applies._"
fi
} > "$OUT"
chmod 600 "$OUT" # it holds the root password
echo "Wrote $OUT"