Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit d8c894d

Browse files
committed
refactor: [#28] separate provider templates from user-generated files
- Move provider templates to infrastructure/config/templates/providers/ - Create missing libvirt.env.tpl template with comprehensive configuration options - Add .gitignore to protect user provider configurations from git commits - Add README.md with setup instructions and security guidelines - Update Makefile infra-providers command to show template vs user file locations - Maintain separation of concerns: templates (tracked) vs user configs (git-ignored) Fixes issue where provider templates and user configs were mixed in same directory. All provider configuration files with credentials are now properly git-ignored.
1 parent 4e529dc commit d8c894d

File tree

5 files changed

+144
-1
lines changed

5 files changed

+144
-1
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,19 @@ infra-refresh-state: check-infra-params ## Refresh Terraform state to detect IP
112112
# Provider and environment information
113113
infra-providers: ## List available infrastructure providers
114114
@echo "Available Infrastructure Providers:"
115-
@$(SCRIPTS_DIR)/providers/provider-interface.sh list || echo "No providers found"
115+
@echo "Templates (infrastructure/config/templates/providers/):"
116+
@ls infrastructure/config/templates/providers/*.env.tpl 2>/dev/null | \
117+
xargs -I {} basename {} | sed 's/\.env.*//g' | sort | uniq || \
118+
echo " No templates found"
119+
@echo ""
120+
@echo "User configurations (infrastructure/config/providers/):"
121+
@ls infrastructure/config/providers/*.env 2>/dev/null | \
122+
xargs -I {} basename {} | sed 's/\.env.*//g' | sort | uniq || \
123+
echo " No user configs found"
124+
@echo ""
125+
@echo "Provider types:"
126+
@echo " libvirt - Local KVM/libvirt virtualization for development"
127+
@echo " hetzner - Hetzner Cloud for production deployments"
116128
@echo ""
117129
@echo "Usage examples:"
118130
@echo " make infra-apply ENVIRONMENT=development PROVIDER=libvirt"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Ignore all user-generated provider configuration files
2+
# These contain credentials and secrets and should never be committed
3+
4+
# Provider configuration files (contain secrets)
5+
*.env
6+
7+
# Backup files
8+
*.env.bak
9+
*.env.backup
10+
11+
# Editor temporary files
12+
*.tmp
13+
*.swp
14+
*.swo
15+
*~
16+
17+
# Allow this directory structure
18+
!.gitignore
19+
!README.md
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Provider Configuration Directory
2+
3+
This directory contains **user-generated provider configuration files** with real
4+
credentials and settings. These files are ignored by git to protect sensitive information.
5+
6+
## File Structure
7+
8+
- `*.env` - User-generated provider configuration files (git-ignored)
9+
- `.gitignore` - Protects user files from being committed
10+
- `README.md` - This documentation file
11+
12+
## Template Source
13+
14+
Templates for creating these files are located at:
15+
16+
```text
17+
infrastructure/config/templates/providers/
18+
```
19+
20+
## Available Providers
21+
22+
### LibVirt Provider (Local Testing)
23+
24+
- **Template**: `infrastructure/config/templates/providers/libvirt.env.tpl`
25+
- **User File**: `libvirt.env` (create from template)
26+
- **Purpose**: Local KVM/libvirt virtualization for development and testing
27+
28+
### Hetzner Cloud Provider (Production)
29+
30+
- **Template**: `infrastructure/config/templates/providers/hetzner.env.tpl`
31+
- **User File**: `hetzner.env` (create from template)
32+
- **Purpose**: Hetzner Cloud deployment for production environments
33+
34+
## Usage Instructions
35+
36+
1. **Copy the appropriate template:**
37+
38+
```bash
39+
# For local testing
40+
cp infrastructure/config/templates/providers/libvirt.env.tpl infrastructure/config/providers/libvirt.env
41+
42+
# For Hetzner Cloud
43+
cp infrastructure/config/templates/providers/hetzner.env.tpl infrastructure/config/providers/hetzner.env
44+
```
45+
46+
2. **Edit the copied file** with your actual values:
47+
- Replace placeholder tokens with real API keys
48+
- Configure VM sizes and locations
49+
- Set appropriate defaults for your use case
50+
51+
3. **Never commit these files** - they contain secrets and are automatically git-ignored
52+
53+
## Security Notes
54+
55+
- ⚠️ **Never commit `*.env` files** - they contain credentials and secrets
56+
-**Always use templates** - copy from `templates/providers/` directory
57+
- 🔄 **Keep templates updated** - contribute improvements back to templates
58+
- 🔒 **Protect access** - these files contain API tokens and configuration secrets
59+
60+
## Backup Strategy
61+
62+
Since these files are git-ignored, consider:
63+
64+
- Storing encrypted backups of your provider configurations
65+
- Using a password manager for API tokens
66+
- Documenting your configuration choices separately
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# LibVirt Provider Configuration Template
2+
# Copy this file to libvirt.env and customize as needed
3+
# Location: infrastructure/config/providers/libvirt.env
4+
5+
# === LIBVIRT PROVIDER SETTINGS ===
6+
# LibVirt connection URI - use qemu:///system for system-wide libvirt
7+
PROVIDER_LIBVIRT_URI="qemu:///system"
8+
9+
# Storage pool name - should be created during libvirt setup
10+
PROVIDER_LIBVIRT_POOL="user-default"
11+
12+
# Network name - typically 'default' for NAT networking
13+
PROVIDER_LIBVIRT_NETWORK="default"
14+
15+
# Base Ubuntu cloud image URL for VM creation
16+
PROVIDER_LIBVIRT_BASE_IMAGE_URL="https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
17+
18+
# === VM DEFAULTS FOR LIBVIRT ===
19+
# These can be overridden by environment configurations
20+
# Recommended minimums for Torrust Tracker demo
21+
VM_MEMORY_DEFAULT=2048 # 2GB RAM minimum
22+
VM_VCPUS_DEFAULT=2 # 2 CPU cores
23+
VM_DISK_SIZE_DEFAULT=20 # 20GB primary disk
24+
PERSISTENT_DATA_SIZE_DEFAULT=20 # 20GB for persistent data volume
25+
26+
# === LIBVIRT-SPECIFIC SETTINGS ===
27+
# Use minimal config for faster development iterations
28+
# Set to true to skip heavy services like Grafana/Prometheus during development
29+
USE_MINIMAL_CONFIG_DEFAULT=false
30+
31+
# === REFERENCE: TYPICAL CONFIGURATIONS ===
32+
# Development/Testing:
33+
# VM_MEMORY_DEFAULT=2048, VM_VCPUS_DEFAULT=2, VM_DISK_SIZE_DEFAULT=20
34+
#
35+
# Production Testing:
36+
# VM_MEMORY_DEFAULT=4096, VM_VCPUS_DEFAULT=4, VM_DISK_SIZE_DEFAULT=40
37+
#
38+
# Performance Testing:
39+
# VM_MEMORY_DEFAULT=8192, VM_VCPUS_DEFAULT=4, VM_DISK_SIZE_DEFAULT=80
40+
41+
# === NOTES ===
42+
# • LibVirt provider is designed for local development and testing
43+
# • Requires KVM virtualization support and libvirt installed
44+
# • The default network provides NAT access to the internet
45+
# • Storage uses the specified pool which should be created during setup
46+
# • For production deployments, consider using Hetzner Cloud provider instead

0 commit comments

Comments
 (0)