fix: adopt existing OCI Bastion and email subnet
This commit is contained in:
parent
f169c4b963
commit
f72ad444ff
|
|
@ -3696,6 +3696,13 @@ oci_foundation_reconcile_existing() {
|
|||
discovered_bastion_id="$("${oci_bin}" bastion bastion list \
|
||||
--compartment-id "${bastion_compartment_id}" --all \
|
||||
--query 'data[0].id' --raw-output 2>/dev/null || true)"
|
||||
if [[ -z "${discovered_bastion_id}" || "${discovered_bastion_id}" == "null" ]]; then
|
||||
discovered_bastion_id="$("${oci_bin}" bastion bastion list \
|
||||
--compartment-id "${LAB_OCI_TENANCY_ID}" \
|
||||
--compartment-id-in-subtree true --all \
|
||||
--query "data[?name==\`${LAB_OCI_BASTION_NAME:-homelab-bastion}\`].id | [0]" \
|
||||
--raw-output 2>/dev/null || true)"
|
||||
fi
|
||||
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}"
|
||||
|
|
@ -3706,7 +3713,20 @@ oci_foundation_reconcile_existing() {
|
|||
# A persisted email subnet CIDR can belong to an older VCN. Select a free
|
||||
# deterministic /24 inside the current VCN rather than failing late at OCI.
|
||||
if [[ -n "${LAB_OCI_EXISTING_VCN_ID:-}" && -z "${LAB_OCI_EXISTING_EMAIL_SUBNET_ID:-}" && -n "${LAB_OCI_EMAIL_SUBNET_CIDR:-}" ]] && command -v python3 >/dev/null 2>&1; then
|
||||
local vcn_cidr corrected_email_cidr
|
||||
local vcn_cidr corrected_email_cidr existing_email_subnet_id
|
||||
local vcn_compartment_id
|
||||
vcn_compartment_id="$("${oci_bin}" network vcn get --vcn-id "${LAB_OCI_EXISTING_VCN_ID}" \
|
||||
--query 'data."compartment-id"' --raw-output 2>/dev/null || true)"
|
||||
if [[ -n "${vcn_compartment_id}" ]]; then
|
||||
existing_email_subnet_id="$("${oci_bin}" network subnet list \
|
||||
--compartment-id "${vcn_compartment_id}" --vcn-id "${LAB_OCI_EXISTING_VCN_ID}" --all \
|
||||
--query 'data[?"display-name"==`homelab-email-subnet`].id | [0]' \
|
||||
--raw-output 2>/dev/null || true)"
|
||||
if [[ -n "${existing_email_subnet_id}" && "${existing_email_subnet_id}" != "null" ]]; then
|
||||
export LAB_OCI_EXISTING_EMAIL_SUBNET_ID="${existing_email_subnet_id}"
|
||||
printf 'Reusing existing OCI email subnet (%s).\n' "${existing_email_subnet_id}"
|
||||
fi
|
||||
fi
|
||||
vcn_cidr="$("${oci_bin}" network vcn get --vcn-id "${LAB_OCI_EXISTING_VCN_ID}" \
|
||||
--query 'data."cidr-blocks"[0]' --raw-output 2>/dev/null || true)"
|
||||
corrected_email_cidr="$(python3 - "${vcn_cidr}" "${LAB_OCI_EMAIL_SUBNET_CIDR}" <<'PY'
|
||||
|
|
|
|||
Loading…
Reference in New Issue