AI-Development-Server/docs/REBUILD-GUIDE.md

172 lines
5.3 KiB
Markdown

# Rebuild Guide
This guide describes the planned rebuild path for Atlas. At Phase 1, the repository contains documentation but no executable installation phases. Steps marked as TODO are not yet automated.
## Automation Status
- Repository structure and documentation: present.
- Shared installation framework: present.
- System discovery script: present.
- Host validation script: present.
- Component installation scripts: not yet created.
- Configuration templates: not yet created.
- Operational scripts: not yet created.
- Smoke tests: not yet created.
- Backup and restore automation: not yet created.
## Preconditions
- Physical server hardware is available.
- Ubuntu 26.04 LTS installation media is available.
- Network details for Atlas are known.
- Gitea SSH access can be restored or re-created.
- Required secrets and private keys are available from an approved location outside this repository.
- Backups are available where required.
Backup inventory and credential recovery process are `TODO: Confirm during the relevant implementation phase.`
## 1. Ubuntu Installation
1. Install Ubuntu 26.04 LTS on the OS SSD.
2. Set hostname to `atlas`.
3. Create the dedicated development user.
4. Configure administrative access for the development user.
5. Apply operating system updates.
Exact installer choices, partitioning profile, and user creation procedure are `TODO: Confirm during the relevant implementation phase.`
## 2. Storage Preparation
Target storage layout:
- OS volume mounted at `/`
- SQL data volume mounted at `/sql`
- Development volume mounted at `/srv`
- Repository root at `/srv/repos`
Current Phase 1 status:
- `/sql` is the intended SQL data volume.
- `/srv` is the primary development volume.
- Idempotent storage preparation scripts do not exist yet.
Future rebuild work must document:
- Disk identification method.
- Filesystem labels or UUIDs.
- `/etc/fstab` entries.
- Mount validation commands.
- Ownership and permissions.
These details are `TODO: Confirm during the relevant implementation phase.`
## 3. Network Setup
Target identity:
- Hostname: `atlas`
- Static IP address: `192.168.10.10`
- Default gateway: `192.168.10.1`
- Primary interface: `enp3s0`
Configure DNS, host mappings, firewall rules, and public exposure only after the relevant policy is confirmed.
DNS and firewall details are `TODO: Confirm during the relevant implementation phase.`
## 4. SSH
1. Install or enable OpenSSH.
2. Confirm SSH access from trusted administration clients.
3. Restore or create the SSH key needed for Gitea access.
4. Keep private keys outside this repository.
SSH hardening policy, trusted client list, and key rotation procedure are `TODO: Confirm during the relevant implementation phase.`
## 5. Repository Checkout
Create the repository root if needed:
```bash
sudo mkdir -p /srv/repos
```
Clone the infrastructure repository:
```bash
cd /srv/repos
git clone git@git.catherinelynwood.com:atlas-bot/AI-Development-Server.git
cd AI-Development-Server
```
If the remote repository is unavailable, follow the disaster recovery guidance in [DISASTER-RECOVERY.md](DISASTER-RECOVERY.md).
## 6. Bootstrap Process
At Phase 1, bootstrap is manual. Future bootstrap should be reduced to a documented command sequence that runs idempotent scripts from this repository.
Planned bootstrap flow:
1. Review [README.md](../README.md).
2. Review [SERVER-STANDARDS.md](../SERVER-STANDARDS.md).
3. Review this rebuild guide.
4. Run `scripts/system/discover-system.sh`.
5. Run `scripts/system/validate-host.sh`.
6. Run `install/bootstrap.sh --dry-run`.
7. Run ordered installation scripts from `install/phases/` when they exist.
8. Run smoke tests from `tests/` when they exist.
Bootstrap command sequence is `TODO: Confirm during the relevant implementation phase.`
## 7. Running Installation Phases
Planned scripts may include:
```text
install/phases/10-dotnet.sh
install/phases/20-sql-server.sh
install/phases/30-nginx.sh
install/phases/40-docker.sh
```
These scripts do not exist yet. When created, each script must:
- Be idempotent.
- Validate prerequisites.
- Log concise progress.
- Avoid printing secrets.
- Document rollback expectations.
- Include or reference validation steps.
## 8. Validation
Minimum rebuild validation should confirm:
- Hostname is `atlas`.
- Static IP address is `192.168.10.10`.
- `/sql` is mounted.
- `/srv` is mounted.
- `/srv/repos` exists.
- Git can reach Gitea over SSH.
- This repository is checked out.
- Required installation phases have run successfully.
- Smoke tests pass.
Validation scripts are currently available at `scripts/system/discover-system.sh` and `scripts/system/validate-host.sh`.
Phase 2A host validation currently checks `/` has at least 10 GiB free, `/srv` has at least 20 GiB free, and `/sql` has at least 20 GiB free.
## 9. Restoring Services and Data
Restoration order should be:
1. Restore base OS access.
2. Restore storage mounts.
3. Restore repository access.
4. Run installation automation.
5. Restore configuration generated from templates.
6. Restore SQL data from verified backups.
7. Restore deployed applications or rebuild them from source.
8. Validate services and application behaviour.
SQL backup location, deployment artefact policy, restore commands, and service validation are `TODO: Confirm during the relevant implementation phase.`