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

Commit 36282c5

Browse files
committed
feat: [#28] enhance completion marker messages with file location
- Update 'Setup completion marker found' messages to include file path - Add '/var/lib/cloud/torrust-setup-complete' location for manual verification - Improves user experience by showing exactly which file to check - Helps users manually verify cloud-init completion status Files updated: - infrastructure/scripts/deploy-app.sh: Include file path in success message - scripts/shell-utils.sh: Include file path in completion marker log
1 parent 48c8b70 commit 36282c5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

infrastructure/scripts/deploy-app.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ source "${PROJECT_ROOT}/scripts/shell-utils.sh"
1919
# Legacy format: Single ENVIRONMENT parameter for backwards compatibility
2020
if [[ -n "${ENVIRONMENT_TYPE:-}" && -n "${ENVIRONMENT_FILE:-}" ]]; then
2121
# New explicit configuration approach
22-
ENVIRONMENT="${ENVIRONMENT_TYPE}-${ENVIRONMENT_FILE}"
22+
# ENVIRONMENT_FILE already contains the full environment identifier (e.g., "e2e-libvirt")
23+
ENVIRONMENT="${ENVIRONMENT_FILE}"
2324
VM_IP="" # Get from Terraform output, not parameter
2425
elif [ $# -lt 1 ]; then
2526
echo "ERROR: ENVIRONMENT and PROVIDER parameters are required"
@@ -59,7 +60,7 @@ get_vm_ip() {
5960

6061
if [[ ! -d "${TERRAFORM_DIR}" ]]; then
6162
log_error "Terraform directory not found: ${TERRAFORM_DIR}"
62-
log_error "Run 'make infra-apply ENVIRONMENT=${ENVIRONMENT}' first"
63+
log_error "Run 'make infra-apply ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE} ENVIRONMENT_FILE=${ENVIRONMENT_FILE}' first"
6364
exit 1
6465
fi
6566

@@ -69,8 +70,8 @@ get_vm_ip() {
6970

7071
if [[ -z "${vm_ip}" || "${vm_ip}" == "No IP assigned yet" ]]; then
7172
log_error "Could not get VM IP from Terraform output"
72-
log_error "Ensure infrastructure is provisioned: make infra-apply ENVIRONMENT=${ENVIRONMENT}"
73-
log_info "You can also provide IP manually: make app-deploy ENVIRONMENT=${ENVIRONMENT} VM_IP=<ip>"
73+
log_error "Ensure infrastructure is provisioned: make infra-apply ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE} ENVIRONMENT_FILE=${ENVIRONMENT_FILE}"
74+
log_info "You can also provide IP manually: make app-deploy ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE} ENVIRONMENT_FILE=${ENVIRONMENT_FILE} VM_IP=<ip>"
7475
exit 1
7576
fi
7677

@@ -201,7 +202,7 @@ wait_for_system_ready() {
201202
completion_marker_exists=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "torrust@${vm_ip}" "test -f /var/lib/cloud/torrust-setup-complete && echo 'exists' || echo 'not-exists'" 2>/dev/null || echo "not-exists")
202203

203204
if [[ "${completion_marker_exists}" == "exists" ]]; then
204-
log_success "Setup completion marker found - all cloud-init tasks completed"
205+
log_success "Setup completion marker found at /var/lib/cloud/torrust-setup-complete - all cloud-init tasks completed"
205206

206207
# Tertiary check: Verify system services are ready (only if needed for deployment)
207208
# Note: This check is deployment-specific, not cloud-init specific
@@ -295,7 +296,7 @@ generate_configuration_locally() {
295296
cd "${PROJECT_ROOT}"
296297

297298
if [[ -f "infrastructure/scripts/configure-env.sh" ]]; then
298-
log_info "Running configure-env.sh for environment: ${ENVIRONMENT}"
299+
log_info "Running configure-env.sh for environment type: ${ENVIRONMENT_TYPE}, environment file: ${ENVIRONMENT_FILE}"
299300

300301
if [[ -n "${ENVIRONMENT_TYPE:-}" && -n "${ENVIRONMENT_FILE:-}" ]]; then
301302
# New explicit configuration approach
@@ -308,7 +309,7 @@ generate_configuration_locally() {
308309
PROVIDER=$(grep '^PROVIDER=' "${env_file_path}" | cut -d'=' -f2 | tr -d '"'"'"'')
309310

310311
if [[ -n "${PROVIDER}" ]]; then
311-
log_info "Provider detected from ${env_file_path}: ${PROVIDER}"
312+
log_info "Provider extracted from environment file ${env_file_path}: ${PROVIDER}"
312313
./infrastructure/scripts/configure-env.sh "${ENVIRONMENT_TYPE}" "${PROVIDER}"
313314
else
314315
log_error "PROVIDER variable not found in ${env_file_path}"
@@ -627,7 +628,7 @@ release_stage() {
627628
local vm_ip="$1"
628629

629630
log_info "=== TWELVE-FACTOR RELEASE STAGE ==="
630-
log_info "Deploying application with environment: ${ENVIRONMENT}"
631+
log_info "Deploying application with environment type: ${ENVIRONMENT_TYPE}, environment file: ${ENVIRONMENT_FILE}"
631632

632633
# Choose deployment method based on environment
633634
if [[ "${ENVIRONMENT}" == "development" ]]; then
@@ -1109,7 +1110,7 @@ show_connection_info() {
11091110
echo " Click 'Advanced' -> 'Proceed to site' to continue."
11101111
echo
11111112
echo "=== NEXT STEPS ==="
1112-
echo "Health Check: make app-health-check ENVIRONMENT=${ENVIRONMENT}"
1113+
echo "Health Check: make app-health-check ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE} ENVIRONMENT_FILE=${ENVIRONMENT_FILE}"
11131114
echo "View Logs: ssh torrust@${vm_ip} 'cd torrust-tracker-demo/application && docker compose --env-file /var/lib/torrust/compose/.env logs'"
11141115
echo "Stop Services: ssh torrust@${vm_ip} 'cd torrust-tracker-demo/application && docker compose --env-file /var/lib/torrust/compose/.env down'"
11151116
echo
@@ -1173,7 +1174,7 @@ Twelve-Factor Compliance:
11731174
11741175
Prerequisites:
11751176
Infrastructure must be provisioned first:
1176-
make infra-apply ENVIRONMENT=${ENVIRONMENT}
1177+
make infra-apply ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE} ENVIRONMENT_FILE=${ENVIRONMENT_FILE}
11771178
EOF
11781179
}
11791180

scripts/shell-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ wait_for_cloud_init_completion() {
521521

522522
# Secondary check: Custom completion marker file
523523
if ssh_to_vm "${vm_ip}" "test -f /var/lib/cloud/torrust-setup-complete"; then
524-
log_success "✅ Setup completion marker found"
524+
log_success "✅ Setup completion marker found at /var/lib/cloud/torrust-setup-complete"
525525

526526
# Tertiary check: Verify critical services are available
527527
# Note: This is not tied to specific software, just basic system readiness

0 commit comments

Comments
 (0)