import models.server import models.taskserv // Local Development Infrastructure Definition // This configuration creates a simple local development environment // with web and database servers suitable for learning and development // Infrastructure metadata metadata: { name = "local-development" description = "Local development environment for learning provisioning" version = "1.0.0" environment = "development" owner = "developer" created = "2024-01-01" // Tags for organization tags = { purpose = "learning" complexity = "beginner" cost_level = "free" } } // Server configurations servers: [ // Web development server server.Server { name = "web-dev-01" provider = "local" plan = "development" // Small resources for local dev os = "ubuntu-22.04" zone = "local-zone-1" // Development-specific settings auto_start = True development_mode = True // Network configuration network = { private_ip = "192.168.100.10" public_ip = False // No public IP needed for local dev // Open common development ports ports = [ 80, // HTTP 443, // HTTPS 22, // SSH 3000, // Node.js dev server 8080, // Alternative HTTP 9000 // Development tools ] } // Storage configuration storage = { root_size = "10GB" type = "local" mount_point = "/var/www" backup_enabled = False // No backups needed for local dev } // Resource limits (conservative for local development) resources = { cpu_cores = 1 memory = "1GB" swap = "512MB" } // Labels and tags tags = { environment = "development" role = "web-server" team = "engineering" backup_required = "false" } // Services to install on this server taskservs = [ "containerd", // Container runtime "nginx", // Web server "nodejs", // Node.js runtime "git" // Version control ] } // Database development server server.Server { name = "db-dev-01" provider = "local" plan = "development" os = "ubuntu-22.04" zone = "local-zone-1" auto_start = True development_mode = True network = { private_ip = "192.168.100.11" public_ip = False ports = [ 22, // SSH 5432, // PostgreSQL 6379, // Redis 3306, // MySQL (optional) 27017 // MongoDB (optional) ] } storage = { root_size = "15GB" // Extra space for database storage type = "local" mount_point = "/var/lib" // Additional storage for database data additional_volumes = [ { name = "database-data" size = "10GB" mount_point = "/var/lib/postgresql" } { name = "redis-data" size = "2GB" mount_point = "/var/lib/redis" } ] } resources = { cpu_cores = 1 memory = "1GB" swap = "1GB" // Databases can benefit from swap } tags = { environment = "development" role = "database-server" team = "engineering" backup_required = "false" } taskservs = [ "containerd", "postgresql", "redis", "git" ] } ] // Network configuration network: { // VPC-like configuration for local development vpc_cidr = "192.168.100.0/24" subnets = [ { name = "development" cidr = "192.168.100.0/28" zone = "local-zone-1" public = False // Private network for local dev } ] // Security groups (firewall rules) security_groups = [ { name = "development-web" description = "Security group for web development servers" rules = [ { protocol = "tcp" port_range = "22" source = "192.168.100.0/24" description = "SSH access" } { protocol = "tcp" port_range = "80" source = "192.168.100.0/24" description = "HTTP access" } { protocol = "tcp" port_range = "443" source = "192.168.100.0/24" description = "HTTPS access" } { protocol = "tcp" port_range = "3000-9000" source = "192.168.100.0/24" description = "Development server ports" } ] } { name = "development-database" description = "Security group for database development servers" rules = [ { protocol = "tcp" port_range = "22" source = "192.168.100.0/24" description = "SSH access" } { protocol = "tcp" port_range = "5432" source = "192.168.100.0/24" description = "PostgreSQL access" } { protocol = "tcp" port_range = "6379" source = "192.168.100.0/24" description = "Redis access" } ] } ] } // Task service configurations taskservs: { // Container runtime configuration containerd: { version = "latest" development_mode = True config = { root = "/var/lib/containerd" debug = True } } // Nginx web server configuration nginx: { version = "latest" development_mode = True config = { // Development-friendly nginx configuration worker_processes = 1 error_log_level = "debug" access_log_enabled = True // Default server configuration server = { listen_port = 80 server_name = "localhost" document_root = "/var/www/html" index = ["index.html", "index.php"] // Enable useful development features autoindex = True // Directory listing try_files = True } // Development-specific modules modules = [ "http_rewrite_module", "http_ssl_module", "http_realip_module" ] } // Sites configuration sites = [ { name = "default" domain = "localhost" document_root = "/var/www/html" ssl_enabled = False // Keep it simple for local dev } ] } // PostgreSQL database configuration postgresql: { version = "14" development_mode = True config = { // Development database settings port = 5432 max_connections = 20 // Lower limit for local dev shared_buffers = "64MB" // Conservative memory usage // Development-friendly settings log_statement = "all" // Log all queries for debugging log_duration = True log_line_prefix = "[%t] %u@%d " // Authentication (development only!) authentication = { method = "trust" // WARNING: Only for local dev! local_connections = "trust" host_connections = "md5" } // Database initialization databases = [ { name = "development" owner = "postgres" encoding = "UTF8" } { name = "test" owner = "postgres" encoding = "UTF8" } ] // Development users users = [ { name = "developer" password = "dev123" // WARNING: Only for local dev! superuser = False databases = ["development", "test"] } ] } } // Redis configuration redis: { version = "latest" development_mode = True config = { port = 6379 bind = "127.0.0.1" // Development settings save_disabled = True // No persistence needed in dev maxmemory = "128MB" // Limit memory usage maxmemory_policy = "allkeys-lru" // Logging for development loglevel = "debug" logfile = "/var/log/redis/redis.log" } } // Node.js runtime nodejs: { version = "18" // LTS version development_mode = True config = { // Global packages useful for development global_packages = [ "nodemon", // Auto-restart on file changes "pm2", // Process manager "express-generator", // Express app generator "@angular/cli", // Angular CLI "create-react-app" // React app generator ] // Development environment variables environment = { NODE_ENV = "development" DEBUG = "*" } } } // Git version control git: { version = "latest" config = { // Global git configuration for development global_config = { "user.name" = "Developer" "user.email" = "dev@localhost" "init.defaultBranch" = "main" "core.editor" = "nano" } } } } // Development environment specific configurations development_config: { // Automatic cleanup settings auto_cleanup = { enabled = True cleanup_on_shutdown = True preserve_data = False // OK to lose data in local dev } // Development tools and utilities dev_tools = { shell_aliases = True // Install useful aliases vim_config = True // Basic vim configuration tmux_config = True // Terminal multiplexer setup docker_compose = True // Docker compose for local services } // Monitoring (lightweight for local dev) monitoring = { enabled = True metrics_retention = "1d" // Short retention for local dev alerting_enabled = False // No alerts needed locally } } // Validation rules check: len(servers) >= 2, "At least 2 servers required for web + database" all server in servers { server.provider == "local" }, "All servers must use local provider for this example" network.vpc_cidr != None, "Network configuration required"