# Provisioning Platform Bootstrap\n\nSimple, flexible bootstrap script for provisioning platform installation.\n\n**No Rust compilation required** - uses pure Bash + Nushell.\n\n## Quick Start\n\n### From Git Repository\n\n```\ngit clone https://github.com/provisioning/provisioning.git\ncd provisioning\n\n# Run bootstrap\n./provisioning/bootstrap/install.sh\n```\n\n### What it Does (7 Stages)\n\n1. **System Detection** - Detects OS, CPU, RAM, architecture\n2. **Dependency Check** - Validates Docker, Rust, Nushell installed\n3. **Directory Structure** - Creates workspace directories\n4. **Configuration Validation** - Validates Nickel config syntax\n5. **Export Configuration** - Exports config.ncl → TOML for services\n6. **Initialize Orchestrator** - Starts orchestrator service\n7. **Verification** - Confirms all files created and services running\n\n## Usage\n\n### Standard Bootstrap (Interactive)\n\n```\n./provisioning/bootstrap/install.sh\n```\n\n### Nushell Direct\n\n```\nnu provisioning/bootstrap/install.nu $(pwd)\n```\n\n## Requirements\n\n**Minimum**:\n\n- Nushell 0.109.0+ (auto-installed if missing)\n- Docker (for containers)\n- Rust + Cargo (for building services)\n- Git (for cloning)\n\n**Recommended**:\n\n- 2+ GB RAM\n- 10+ GB disk\n- macOS, Linux, or WSL2\n\n## What Gets Created\n\nAfter bootstrap, your workspace has:\n\n```\nworkspace_librecloud/\n├── config/\n│ ├── config.ncl ← Master config (Nickel)\n│ └── generated/ ← Auto-exported TOML\n│ ├── workspace.toml\n│ ├── providers/\n│ │ ├── upcloud.toml\n│ │ └── local.toml\n│ └── platform/\n│ └── orchestrator.toml\n├── .orchestrator/data/queue/ ← Orchestrator data\n├── .kms/ ← KMS data\n├── .providers/ ← Provider state\n├── .taskservs/ ← Task service data\n└── .clusters/ ← Cluster data\n```\n\n## Differences from Rust Installer\n\n| Feature | Rust Installer | Bash+Nushell Bootstrap |\n| --------- | ----------------- | ------------------------ |\n| **Requires compilation** | ✅ Yes (5+ min) | ❌ No |\n| **Flexible** | ⚠️ Limited | ✅ Fully scriptable |\n| **Source code** | ❌ Binary | ✅ Clear scripts |\n| **Easy to modify** | ❌ Recompile | ✅ Edit script |\n| **Integrates with TypeDialog** | ❌ Hard | ✅ Easy |\n| **Deployable everywhere** | ✅ Binary | ✅ Script |\n| **TUI Interface** | ✅ Ratatui | ⚠️ Text menus |\n\n## Troubleshooting\n\n### "Nushell not found"\n\n```\n# Install Nushell manually:\n# macOS:\nbrew install nushell\n\n# Linux (Debian):\nsudo apt install nushell\n\n# Linux (RHEL):\nsudo yum install nushell\n\n# Or: https://nushell.sh/book/installation.html\n```\n\n### "Docker not installed"\n\n```\n# https://docs.docker.com/get-docker/\n```\n\n### "Rust not installed"\n\n```\n# https://rustup.rs/\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nrustup default stable\n```\n\n### "Configuration validation failed"\n\n```\n# Check Nickel syntax\nnickel typecheck workspace_librecloud/config/config.ncl\n\n# Fix errors in config.ncl\nvim workspace_librecloud/config/config.ncl\n\n# Re-run bootstrap\n./provisioning/bootstrap/install.sh\n```\n\n### "Orchestrator didn't start"\n\n```\n# Check logs\ntail -f workspace_librecloud/.orchestrator/logs/orchestrator.log\n\n# Manual start\ncd provisioning/platform/orchestrator\n./scripts/start-orchestrator.nu --background\n\n# Check health\ncurl http://localhost:9090/health\n```\n\n## After Bootstrap\n\nOnce complete:\n\n1. **Verify orchestrator**:\n\n ```bash\n curl http://localhost:9090/health\n ```\n\n1. **Update configuration** (optional):\n\n ```bash\n provisioning config platform orchestrator\n ```\n\n2. **Start provisioning**:\n\n ```bash\n provisioning server create --infra sgoyol --name web-01\n ```\n\n3. **Monitor progress**:\n\n ```bash\n provisioning workflow monitor \n ```\n\n## Development\n\n### Add New Bootstrap Stage\n\nEdit `install.nu` and add:\n\n```\n# Stage N: YOUR STAGE NAME\nprint "🔧 Stage N: Your Stage Name"\nprint "─────────────────────────────────────────────────────────────────"\n\n# Your logic here\n\nprint " ✅ Done"\nprint ""\n```\n\n### Modify Existing Stages\n\nDirect script edits - no compilation needed. Changes take effect immediately.\n\n### Extend Bootstrap\n\nAdd new scripts in `provisioning/bootstrap/` directory:\n\n```\nprovisioning/bootstrap/\n├── install.sh # Entry point\n├── install.nu # Main orchestrator\n├── validators.nu # Validation helpers (future)\n├── generators.nu # Generator helpers (future)\n└── README.md # This file\n```\n\n## Comparison to Old Rust Installer\n\n**Old way**:\n\n1. Run Rust installer binary\n2. Need to recompile for any changes\n3. Difficult to integrate with TypeDialog\n4. Hard to debug\n\n**New way**:\n\n1. Run simple bash script\n2. Changes take effect immediately\n3. Uses existing Nushell libraries\n4. Easy to extend and debug\n\n## FAQ\n\n**Q: Why not keep the Rust installer?**\nA: Rust crate was over-engineered for bootstrap. Bash+Nushell is simpler, more flexible, and integrates better with the rest of the system.\n\n**Q: Can I customize the bootstrap?**\nA: Yes! Edit `install.nu` directly. Add new stages, change logic, integrate TypeDialog - all without compilation.\n\n**Q: What about TUI interface?**\nA: Bootstrap uses text menus. If you need a fancy TUI, you can build a separate Rust tool, but it's not required for basic installation.\n\n**Q: Is this production-ready?**\nA: Yes. It's simpler and more robust than the old Rust installer.\n\n---\n\n**Status**: ✅ Ready for use\n**Last Updated**: 2025-01-02