From 6e9361eb7c25d02a8eed97105bfc574a24b6cf04 Mon Sep 17 00:00:00 2001 From: Clint Branham Date: Wed, 25 Mar 2026 17:12:44 -0500 Subject: [PATCH] fix: mount answer server directory instead of individual file Docker bind mount fails when mounting a file that doesn't exist on the host (creates a directory instead). In CI, the container's $WORK_DIR path differs from the host path, so the file mount failed. Changed to mount a single answer-server/ directory containing both default.toml and answers/ subdirectory. Replaced two TF variables (answer_files_dir, default_answer_file) with one (answer_server_dir). Layout: $WORK_DIR/answer-server/default.toml + answers/.toml Co-Authored-By: Claude Opus 4.6 (1M context) --- .../infrastructure/scripts/run-integration.sh | 20 +++++++++---------- tests/infrastructure/storage.tf | 13 ++++++------ tests/infrastructure/variables.tf | 9 ++------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/tests/infrastructure/scripts/run-integration.sh b/tests/infrastructure/scripts/run-integration.sh index 01bc779..2e67e17 100755 --- a/tests/infrastructure/scripts/run-integration.sh +++ b/tests/infrastructure/scripts/run-integration.sh @@ -186,21 +186,21 @@ cmd_provision() { log "Generating answer files..." local escaped_pve_password escaped_pve_password=$(printf '%s' "$PVE_PASSWORD" | sed 's/[\/&\\]/\\&/g') - mkdir -p "$WORK_DIR/answers" + mkdir -p "$WORK_DIR/answer-server/answers" # Default answer file (fallback for unknown MACs) sed -e "s/\${root_password}/${escaped_pve_password}/" \ -e "s/\${fqdn}/pve-default.test.local/" \ - "$INFRA_DIR/answer.toml.tftpl" > "$WORK_DIR/default-answer.toml" + "$INFRA_DIR/answer.toml.tftpl" > "$WORK_DIR/answer-server/default.toml" for node in $provision_nodes; do local mac fqdn mac="$(pve_mac "$node")" fqdn="$(pve_fqdn "$node")" - # Answer file named by lowercase MAC with colons (server matches on MAC) + # Answer file named by lowercase MAC (server matches on MAC) sed -e "s/\${root_password}/${escaped_pve_password}/" \ -e "s/\${fqdn}/${fqdn}/" \ - "$INFRA_DIR/answer.toml.tftpl" > "$WORK_DIR/answers/${mac}.toml" + "$INFRA_DIR/answer.toml.tftpl" > "$WORK_DIR/answer-server/answers/${mac}.toml" done # Prepare generic HTTP auto-install ISOs (one per PVE version, not per node). @@ -296,8 +296,7 @@ cmd_provision() { TF_VAR_target_node="$PVE_TARGET_NODE" \ TF_VAR_test_vm_password="$PVE_PASSWORD" \ TF_VAR_docker_host_ip="$storage_ip" \ - TF_VAR_answer_files_dir="$WORK_DIR/answers" \ - TF_VAR_default_answer_file="$WORK_DIR/default-answer.toml" \ + TF_VAR_answer_server_dir="$WORK_DIR/answer-server" \ terraform apply -auto-approve -input=false -state="$TF_STATE_FILE" -var-file="$tfvars" $tf_targets) # Wait for PVE instances to boot and discover IPs @@ -558,9 +557,9 @@ cmd_cleanup() { (cd "$INFRA_DIR" && terraform init -input=false 2>/dev/null) - # Ensure answer file paths exist (terraform destroy validates host_path mounts) - mkdir -p "$WORK_DIR/answers" - touch "$WORK_DIR/default-answer.toml" + # Ensure answer server dir exists (terraform destroy validates host_path mounts) + mkdir -p "$WORK_DIR/answer-server/answers" + touch "$WORK_DIR/answer-server/default.toml" # Build -target flags when destroying a subset local tf_targets="" @@ -584,8 +583,7 @@ cmd_cleanup() { TF_VAR_target_node="$PVE_TARGET_NODE" \ TF_VAR_test_vm_password="${PVE_PASSWORD:-placeholder}" \ TF_VAR_docker_host_ip="${storage_ip:-127.0.0.1}" \ - TF_VAR_answer_files_dir="${WORK_DIR}/answers" \ - TF_VAR_default_answer_file="${WORK_DIR}/default-answer.toml" \ + TF_VAR_answer_server_dir="${WORK_DIR}/answer-server" \ terraform destroy -auto-approve -input=false -state="$TF_STATE_FILE" -var-file="$tfvars" $tf_targets) # Clean up work directory when destroying all diff --git a/tests/infrastructure/storage.tf b/tests/infrastructure/storage.tf index ba96439..479f9a6 100644 --- a/tests/infrastructure/storage.tf +++ b/tests/infrastructure/storage.tf @@ -11,14 +11,13 @@ resource "docker_container" "answer_server" { network_mode = "host" + # Mount the answer server root directory which contains: + # default.toml — fallback answer file + # answers/ — per-MAC answer files + # The server expects both at ./default.toml and ./answers/ relative to /app volumes { - host_path = var.answer_files_dir - container_path = "/app/answers" - } - - volumes { - host_path = var.default_answer_file - container_path = "/app/default.toml" + host_path = var.answer_server_dir + container_path = "/app" } } diff --git a/tests/infrastructure/variables.tf b/tests/infrastructure/variables.tf index d08fbc7..8380983 100644 --- a/tests/infrastructure/variables.tf +++ b/tests/infrastructure/variables.tf @@ -95,13 +95,8 @@ variable "docker_host_ip" { type = string } -variable "answer_files_dir" { - description = "Host path to the directory containing per-MAC answer.toml files" - type = string -} - -variable "default_answer_file" { - description = "Host path to the default answer.toml file" +variable "answer_server_dir" { + description = "Host path to the answer server root directory (contains default.toml and answers/ subdirectory)" type = string }