|
1 | 1 | # Makefile for Torrust Tracker Local Testing Infrastructure |
2 | | -.PHONY: help init plan apply destroy test clean status refresh-state ssh install-deps console vm-console lint lint-yaml lint-shell lint-markdown |
| 2 | +.PHONY: help init plan apply destroy test clean status refresh-state ssh install-deps console vm-console lint lint-yaml lint-shell lint-markdown configure-local configure-production validate-config validate-config-production deploy-local deploy-production start-services stop-services |
3 | 3 |
|
4 | 4 | # Default variables |
5 | 5 | VM_NAME ?= torrust-tracker-demo |
@@ -342,3 +342,61 @@ vm-console: ## Access VM graphical console (GUI) |
342 | 342 | echo "virt-viewer not found. Please install it:"; \ |
343 | 343 | echo " sudo apt install virt-viewer"; \ |
344 | 344 | fi |
| 345 | + |
| 346 | +# Configuration Management Targets |
| 347 | +configure-local: ## Generate local environment configuration |
| 348 | + @echo "Generating local environment configuration..." |
| 349 | + @infrastructure/scripts/configure-env.sh local |
| 350 | + |
| 351 | +configure-production: ## Generate production environment configuration (requires secrets) |
| 352 | + @echo "Generating production environment configuration..." |
| 353 | + @infrastructure/scripts/configure-env.sh production |
| 354 | + |
| 355 | +validate-config: ## Validate generated configuration files |
| 356 | + @echo "Validating configuration files..." |
| 357 | + @infrastructure/scripts/validate-config.sh local |
| 358 | + |
| 359 | +validate-config-production: ## Validate production configuration files |
| 360 | + @echo "Validating production configuration files..." |
| 361 | + @infrastructure/scripts/validate-config.sh production |
| 362 | + |
| 363 | +# Deployment workflow targets |
| 364 | +deploy-local: configure-local ## Deploy VM and configure for local environment |
| 365 | + @echo "Deploying local environment..." |
| 366 | + @$(MAKE) apply |
| 367 | + @echo "Waiting for VM to be ready..." |
| 368 | + @sleep 30 |
| 369 | + @echo "Starting application services..." |
| 370 | + @$(MAKE) start-services |
| 371 | + |
| 372 | +deploy-production: configure-production ## Deploy and configure for production environment (requires secrets) |
| 373 | + @echo "Deploying production environment..." |
| 374 | + @$(MAKE) apply |
| 375 | + @echo "Waiting for VM to be ready..." |
| 376 | + @sleep 30 |
| 377 | + @echo "Starting application services..." |
| 378 | + @$(MAKE) start-services |
| 379 | + |
| 380 | +start-services: ## Start Docker Compose services in the VM |
| 381 | + @echo "Starting Docker Compose services..." |
| 382 | + @VM_IP=$$(cd $(TERRAFORM_DIR) && tofu output -raw vm_ip 2>/dev/null) || \ |
| 383 | + VM_IP=$$(virsh domifaddr $(VM_NAME) | grep ipv4 | awk '{print $$4}' | cut -d'/' -f1); \ |
| 384 | + if [ -n "$$VM_IP" ]; then \ |
| 385 | + echo "Starting services on $$VM_IP..."; \ |
| 386 | + ssh -o StrictHostKeyChecking=no torrust@$$VM_IP 'cd /home/torrust/github/torrust/torrust-tracker-demo/application && docker compose up -d'; \ |
| 387 | + else \ |
| 388 | + echo "Could not get VM IP. Is the VM deployed?"; \ |
| 389 | + exit 1; \ |
| 390 | + fi |
| 391 | + |
| 392 | +stop-services: ## Stop Docker Compose services in the VM |
| 393 | + @echo "Stopping Docker Compose services..." |
| 394 | + @VM_IP=$$(cd $(TERRAFORM_DIR) && tofu output -raw vm_ip 2>/dev/null) || \ |
| 395 | + VM_IP=$$(virsh domifaddr $(VM_NAME) | grep ipv4 | awk '{print $$4}' | cut -d'/' -f1); \ |
| 396 | + if [ -n "$$VM_IP" ]; then \ |
| 397 | + echo "Stopping services on $$VM_IP..."; \ |
| 398 | + ssh -o StrictHostKeyChecking=no torrust@$$VM_IP 'cd /home/torrust/github/torrust/torrust-tracker-demo/application && docker compose down'; \ |
| 399 | + else \ |
| 400 | + echo "Could not get VM IP. Is the VM deployed?"; \ |
| 401 | + exit 1; \ |
| 402 | + fi |
0 commit comments