# Remote Deployment Guide

## Issue: Deployment Scripts Require Proxmox Host Access

The deployment scripts (`deploy-all.sh`, etc.) are designed to run **ON the Proxmox host** because they use the `pct` command-line tool, which is only available on Proxmox hosts.

**Error you encountered:**
```
[ERROR] pct command not found. This script must be run on Proxmox host.
```

---

## Solutions

### Option 1: Copy to Proxmox Host (Recommended)

**Best approach:** Copy the deployment package to the Proxmox host and run it there.

#### Step 1: Copy Deployment Package

```bash
# From your local machine
cd /home/intlc/projects/proxmox

# Copy to Proxmox host
scp -r smom-dbis-138-proxmox root@192.168.11.10:/opt/
```

#### Step 2: SSH to Proxmox Host

```bash
ssh root@192.168.11.10
```

#### Step 3: Run Deployment on Host

```bash
cd /opt/smom-dbis-138-proxmox

# Make scripts executable
chmod +x scripts/deployment/*.sh
chmod +x install/*.sh

# Run deployment
./scripts/deployment/deploy-all.sh
```

#### Automated Script

Use the provided script to automate this:

```bash
./scripts/deploy-to-proxmox-host.sh
```

This script will:
1. Copy the deployment package to the Proxmox host
2. SSH into the host
3. Run the deployment automatically

---

### Option 2: Hybrid Approach (API + SSH)

Create containers via API, then configure via SSH.

#### Step 1: Create Containers via API

```bash
# Use the remote deployment script (creates containers via API)
cd smom-dbis-138-proxmox
./scripts/deployment/deploy-remote.sh
```

#### Step 2: Copy Files and Install

```bash
# Copy installation scripts to Proxmox host
scp -r install/ root@192.168.11.10:/opt/smom-dbis-138-proxmox/

# SSH and run installations
ssh root@192.168.11.10
cd /opt/smom-dbis-138-proxmox

# Install in each container
for vmid in 106 107 108 109; do
    pct push $vmid install/besu-validator-install.sh /tmp/install.sh
    pct exec $vmid -- bash /tmp/install.sh
done
```

---

### Option 3: Use MCP Server Tools

The MCP server provides API-based tools that can create containers remotely.

**Available via MCP:**
- Container creation
- Container management
- Configuration

**Limitations:**
- File upload (`pct push`) still requires local access
- Some operations may need local execution

---

## Why `pct` is Required

The `pct` (Proxmox Container Toolkit) command:
- Is only available on Proxmox hosts
- Provides direct access to container filesystem
- Allows file upload (`pct push`)
- Allows command execution (`pct exec`)
- Is more efficient than API for some operations

**API Alternative:**
- Container creation: ✅ Supported
- Container management: ✅ Supported
- File upload: ⚠️ Limited (requires workarounds)
- Command execution: ✅ Supported (with limitations)

---

## Recommended Workflow

### For Remote Deployment:

1. **Copy Package to Host**
   ```bash
   ./scripts/deploy-to-proxmox-host.sh
   ```

2. **Or Manual Copy:**
   ```bash
   scp -r smom-dbis-138-proxmox root@192.168.11.10:/opt/
   ssh root@192.168.11.10
   cd /opt/smom-dbis-138-proxmox
   ./scripts/deployment/deploy-all.sh
   ```

### For Local Deployment:

If you have direct access to the Proxmox host:
```bash
# On Proxmox host
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-all.sh
```

---

## Troubleshooting

### Issue: "pct command not found"

**Solution:** Run deployment on Proxmox host, not remotely.

### Issue: "Permission denied"

**Solution:** Run with `sudo` or as `root` user.

### Issue: "Container creation failed"

**Check:**
- API token has proper permissions
- Storage is available
- Template exists
- Sufficient resources

---

## Summary

**Best Practice:** Copy deployment package to Proxmox host and run there.

**Quick Command:**
```bash
./scripts/deploy-to-proxmox-host.sh
```

This automates the entire process of copying and deploying.

---

**Last Updated:** $(date)

