# Deployment Modes

The Provisioning platform supports three deployment modes designed for different operational
contexts: interactive TUI for guided setup, headless CLI for automation, and unattended mode
for CI/CD pipelines.

## Overview

Deployment modes determine how the platform installer and orchestrator interact with the environment:

| Mode | Use Case | User Interaction | Configuration | Rollback |
| ---- | -------- | ---------------- | ------------- | -------- |
| **Interactive TUI** | First-time setup, exploration | Full interactive terminal UI | Guided wizard | Manual intervention |
| **Headless CLI** | Scripted automation | Command-line flags only | Pre-configured files | Automatic checkpoint |
| **Unattended** | CI/CD pipelines | Zero interaction | Config file required | Automatic rollback |

## Interactive TUI Mode

Beautiful terminal user interface for guided platform installation and configuration.

### When to Use

- First-time platform installation
- Exploring configuration options
- Learning platform features
- Development and testing environments
- Manual infrastructure provisioning

### Features

Seven interactive screens with real-time validation:

1. **Welcome Screen** - Platform overview and prerequisites check
2. **Deployment Mode Selection** - Solo, MultiUser, CICD, Enterprise
3. **Component Selection** - Choose platform services to install
4. **Configuration Builder** - Interactive settings editor
5. **Provider Setup** - Cloud provider credentials and configuration
6. **Review and Confirm** - Summary before installation
7. **Installation Progress** - Real-time tracking with checkpoint recovery

### Starting Interactive Mode

```bash
# Launch interactive installer
provisioning-installer

# Or via main CLI
provisioning install --mode tui
```

### Navigation

```text
Tab/Shift+Tab - Navigate fields
Enter - Select/confirm
Esc - Cancel/go back
Arrow keys - Navigate lists
Space - Toggle checkboxes
Ctrl+C - Exit installer
```

## Headless CLI Mode

Command-line interface for scripted automation without graphical interface.

### When to Use

- Automated deployment scripts
- Remote server installation via SSH
- Reproducible infrastructure provisioning
- Configuration management systems
- Batch deployments across multiple servers

### Features

- Non-interactive installation
- Configuration via command-line flags
- Pre-validation of all inputs
- Structured JSON/YAML output
- Exit codes for script integration
- Checkpoint-based recovery

### Command Syntax

```bash
provisioning-installer --headless \
  --mode <sol| o multiuse| r cic| d enterprise> \
  --components <comma-separated-list> \
  --storage-path <path> \
  --database <backend> \
  --log-level <level> \
  [--yes] \
  [--config <file>]
```

### Example Deployments

Solo developer setup:

```bash
provisioning-installer --headless \
  --mode solo \
  --components orchestrator,control-center \
  --yes
```

CI/CD pipeline deployment:

```bash
provisioning-installer --headless \
  --mode cicd \
  --components orchestrator,vault-service \
  --database surrealdb \
  --yes
```

Enterprise production deployment:

```bash
provisioning-installer --headless \
  --mode enterprise \
  --config /etc/provisioning/enterprise.toml \
  --yes
```

## Unattended Mode

Zero-interaction deployment for fully automated CI/CD pipelines.

### When to Use

- Continuous integration pipelines
- Continuous deployment workflows
- Infrastructure as Code provisioning
- Automated testing environments
- Container image builds
- Cloud instance initialization

### Requirements

1. Configuration file must exist and be valid
2. All required dependencies must be installed
3. Sufficient system resources must be available
4. Network connectivity to required services
5. Appropriate file system permissions

### Command Syntax

```bash
provisioning-installer --unattended --config <config-file>
```

### Example CI/CD Integrations

GitHub Actions workflow:

```yaml
name: Deploy Provisioning Platform
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install prerequisites
        run: |
          curl -sSL  [https://install.nushell.sh](https://install.nushell.sh) | sh
          curl -sSL  [https://install.nickel-lang.org](https://install.nickel-lang.org) | sh

      - name: Deploy provisioning platform
        env:
          PROVISIONING_DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
          UPCLOUD_API_TOKEN: ${{ secrets.UPCLOUD_TOKEN }}
        run: |
          provisioning-installer --unattended --config ci-config.toml

      - name: Verify deployment
        run: |
          curl -f  [http://localhost:8080/health](http://localhost:8080/health) | | exit 1
```

## Resource Requirements by Mode

### Solo Mode

**Minimum:** 2 CPU, 4GB RAM, 20GB disk
**Recommended:** 4 CPU, 8GB RAM, 50GB disk

### MultiUser Mode

**Minimum:** 4 CPU, 8GB RAM, 50GB disk
**Recommended:** 8 CPU, 16GB RAM, 100GB disk

### CICD Mode

**Minimum:** 8 CPU, 16GB RAM, 100GB disk
**Recommended:** 16 CPU, 32GB RAM, 500GB disk

### Enterprise Mode

**Minimum:** 16 CPU, 32GB RAM, 500GB disk
**Recommended:** 32+ CPU, 64GB+ RAM, 1TB+ disk

## Choosing the Right Mode

| Scenario | Recommended Mode | Rationale |
| -------- | ---------------- | --------- |
| First-time installation | Interactive TUI | Guided setup with validation |
| Manual production setup | Interactive TUI | Review all settings before deployment |
| Ansible playbook | Headless CLI | Scriptable without GUI |
| Remote server via SSH | Headless CLI | Works without terminal UI |
| GitHub Actions | Unattended | Zero interaction, strict validation |
| Docker image build | Unattended | Non-interactive environment |

## Best Practices

### Interactive TUI Mode

- Review all configuration screens carefully
- Save configuration for later reuse
- Document custom settings

### Headless CLI Mode

- Test configuration on development environment first
- Use `--check` flag for dry-run validation
- Store configurations in version control
- Use environment variables for sensitive data

### Unattended Mode

- Validate configuration files extensively before CI/CD deployment
- Test rollback behavior in non-production environments
- Monitor installation logs in real-time
- Set up alerting for installation failures
- Use idempotent operations to allow retry

## Related Documentation

- [Service Management](service-management.md) - Managing installed services
- [Platform Health](platform-health.md) - Monitoring platform status
- [Troubleshooting](troubleshooting.md) - Debugging deployment issues
