# Proxmox Review and Planning Scripts

This directory contains scripts for connecting to Proxmox instances, reviewing configurations, checking status, and generating deployment plans.

## Scripts

### 1. `proxmox-review-and-plan.sh` (Bash)

A comprehensive bash script that:
- Connects to both Proxmox instances
- Reviews current configurations
- Checks cluster and node status
- Generates deployment plans
- Creates detailed task lists

**Requirements**:
- `curl` (required)
- `jq` (optional, for better JSON parsing)

**Usage**:
```bash
./scripts/proxmox-review-and-plan.sh
```

**Output**: Files are generated in `docs/proxmox-review/`

### 2. `proxmox-review-and-plan.py` (Python)

A Python script with more detailed API interactions:
- Better error handling
- More comprehensive status gathering
- Detailed node information collection

**Requirements**:
- Python 3.6+
- `requests` library: `pip install requests`
- `proxmoxer` (optional): `pip install proxmoxer`

**Usage**:
```bash
python3 ./scripts/proxmox-review-and-plan.py
```

**Output**: Files are generated in `docs/proxmox-review/`

## Environment Setup

Before running the scripts, ensure your `.env` file contains:

```env
# Proxmox Instance 1
PROXMOX_1_API_URL=https://192.168.11.10:8006
PROXMOX_1_USER=root
PROXMOX_1_PASS=your-password
PROXMOX_1_API_TOKEN=  # Optional, preferred over password
PROXMOX_1_INSECURE_SKIP_TLS_VERIFY=false

# Proxmox Instance 2
PROXMOX_2_API_URL=https://192.168.11.11:8006
PROXMOX_2_USER=root
PROXMOX_2_PASS=your-password
PROXMOX_2_API_TOKEN=  # Optional, preferred over password
PROXMOX_2_INSECURE_SKIP_TLS_VERIFY=false
```

## Output Files

After running either script, the following files will be generated in `docs/proxmox-review/`:

1. **Configuration Review** (`configuration-review-{timestamp}.md`)
   - Current environment configuration
   - Crossplane provider configuration
   - Cloudflare tunnel configurations

2. **Deployment Plan** (`deployment-plan-{timestamp}.md`)
   - Phased deployment approach
   - Current status summary
   - Deployment phases and steps

3. **Task List** (`task-list-{timestamp}.md`)
   - Detailed task breakdown
   - Priority levels
   - Task descriptions and actions

4. **Status JSONs** (`proxmox-{1|2}-status-{timestamp}.json`)
   - Cluster status
   - Node information
   - Storage configuration
   - VM listings

## Quick Start

1. **Set up environment**:
   ```bash
   cp ENV_EXAMPLES.md .env
   # Edit .env with your Proxmox credentials
   ```

2. **Run review script**:
   ```bash
   ./scripts/proxmox-review-and-plan.sh
   ```

3. **Review output**:
   ```bash
   ls -la docs/proxmox-review/
   cat docs/proxmox-review/task-list-*.md
   ```

4. **Start with high-priority tasks**:
   - Verify connectivity (TASK-001, TASK-002)
   - Test authentication (TASK-003, TASK-004)
   - Review configurations (TASK-005, TASK-006, TASK-007)

## Troubleshooting

### Connection Issues

If you can't connect to Proxmox instances:

1. **Check network connectivity**:
   ```bash
   ping 192.168.11.10
   ping 192.168.11.11
   ```

2. **Test API endpoint**:
   ```bash
   curl -k https://192.168.11.10:8006/api2/json/version
   ```

3. **Verify firewall rules**:
   - Port 8006 should be accessible
   - Check if IP is whitelisted in Proxmox

### Authentication Issues

1. **Verify credentials**:
   - Check username format: `user@realm` (e.g., `root@pam`)
   - Verify password is correct
   - Check if account is locked

2. **Use API tokens** (recommended):
   - Create token in Proxmox Web UI
   - Use format: `user@realm!token-name=token-secret`
   - Set in `.env` as `PROXMOX_*_API_TOKEN`

3. **Test authentication manually**:
   ```bash
   curl -k -X POST \
     -d "username=root@pam&password=your-password" \
     https://192.168.11.10:8006/api2/json/access/ticket
   ```

### Script Errors

1. **Missing dependencies**:
   - Install `jq`: `sudo apt install jq` (Debian/Ubuntu)
   - Install Python packages: `pip install requests proxmoxer`

2. **Permission errors**:
   - Make scripts executable: `chmod +x scripts/*.sh`

3. **JSON parsing errors**:
   - Install `jq` for better parsing
   - Check if API responses are valid JSON

## Related Documentation

- [Proxmox Review Summary](../docs/proxmox/PROXMOX_REVIEW_SUMMARY.md)
- [Task List](../docs/proxmox/TASK_LIST.md)
- [Configuration Guide](../CONFIGURATION_GUIDE.md)
- [Environment Examples](../ENV_EXAMPLES.md)

## Next Steps

After running the review scripts:

1. Review the generated task list
2. Start with high-priority connection tasks
3. Update configurations based on findings
4. Proceed with Crossplane provider deployment
5. Set up monitoring and infrastructure

For detailed task information, see [TASK_LIST.md](../docs/proxmox/TASK_LIST.md).

