diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index df71705..30ed744 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -3756,6 +3756,14 @@ oci_foundation_reconcile_existing() { if [[ -n "${discovered_bastion_id}" && "${discovered_bastion_id}" != "null" ]]; then export LAB_OCI_BASTION_ID="${discovered_bastion_id}" printf 'Reusing existing OCI Bastion (%s).\n' "${discovered_bastion_id}" + elif [[ "${LAB_OCI_BASTION_NAME:-homelab-bastion}" == "homelab-bastion" && -n "${LAB_OCI_COMPARTMENT_ID:-}" ]]; then + # OCI can reject a duplicate Bastion name even when the + # existing Bastion belongs to an older network. Make the new + # Bastion name deterministic for this VCN. + local bastion_suffix + bastion_suffix="${LAB_OCI_COMPARTMENT_ID: -8}" + export LAB_OCI_BASTION_NAME="homelab-bastion-${bastion_suffix}" + printf 'Using network-specific OCI Bastion name %s.\n' "${LAB_OCI_BASTION_NAME}" fi fi fi