Compare commits

..

No commits in common. "b2ffd82dfde41997e8c83e257a8ddc0ccde933ea" and "15e195e121df0de73fa0ea3059c280ab44790da7" have entirely different histories.

9 changed files with 7 additions and 374 deletions

View File

@ -14,10 +14,6 @@ locals {
public_route_table_id = try(oci_core_route_table.public[0].id, null)
private_route_table_id = try(oci_core_route_table.private[0].id, null)
base_tags = merge(var.freeform_tags, { managed_by = "jeannie", purpose = "homelab-learning" })
edge_monitoring_instance_id = trimspace(var.edge_monitoring_instance_id) != "" ? var.edge_monitoring_instance_id : try(oci_core_instance.edge[0].id, try(data.oci_core_instance.monitoring_edge[0].id, try(data.oci_core_instance.existing_edge[0].id, null)))
email_monitoring_instance_id = trimspace(var.email_monitoring_instance_id) != "" ? var.email_monitoring_instance_id : try(oci_core_instance.email[0].id, try(data.oci_core_instance.monitoring_email[0].id, null))
edge_monitoring_compartment_id = try(data.oci_core_instance.monitoring_edge[0].compartment_id, try(data.oci_core_instance.existing_edge[0].compartment_id, local.target_compartment_id))
email_monitoring_compartment_id = try(data.oci_core_instance.monitoring_email[0].compartment_id, local.email_compartment_id)
}
data "oci_core_subnet" "existing_public" {
@ -30,16 +26,6 @@ data "oci_core_vcn" "existing" {
vcn_id = var.existing_vcn_id
}
data "oci_core_instance" "monitoring_edge" {
count = var.enabled && trimspace(var.edge_monitoring_instance_id) != "" ? 1 : 0
instance_id = var.edge_monitoring_instance_id
}
data "oci_core_instance" "monitoring_email" {
count = var.enabled && trimspace(var.email_monitoring_instance_id) != "" ? 1 : 0
instance_id = var.email_monitoring_instance_id
}
data "oci_objectstorage_namespace" "homelab" {
count = var.enabled && var.backup_bucket_enabled ? 1 : 0
compartment_id = var.tenancy_id
@ -62,23 +48,6 @@ resource "oci_objectstorage_bucket" "homelab_backups" {
}
}
resource "oci_ons_notification_topic" "monitoring" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled ? 1 : 0
compartment_id = local.target_compartment_id
name = var.monitoring_topic_name
description = "Jeannie OCI VM monitoring alarms"
freeform_tags = local.base_tags
}
resource "oci_ons_subscription" "monitoring_email" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled && trimspace(var.monitoring_notification_email) != "" ? 1 : 0
compartment_id = local.target_compartment_id
endpoint = var.monitoring_notification_email
protocol = "EMAIL"
topic_id = oci_ons_notification_topic.monitoring[0].id
freeform_tags = local.base_tags
}
resource "oci_identity_policy" "object_storage_lifecycle" {
count = var.enabled && var.backup_bucket_enabled ? 1 : 0
compartment_id = var.tenancy_id
@ -503,71 +472,3 @@ resource "oci_core_instance" "email" {
metadata = { ssh_authorized_keys = var.ssh_public_key }
freeform_tags = merge(local.base_tags, { role = "email" })
}
resource "oci_monitoring_alarm" "edge_cpu_high" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled && local.edge_monitoring_instance_id != null && trimspace(local.edge_monitoring_instance_id) != "" ? 1 : 0
compartment_id = local.edge_monitoring_compartment_id
metric_compartment_id = local.edge_monitoring_compartment_id
namespace = "oci_computeagent"
query = "CpuUtilization[5m]{resourceId = \"${local.edge_monitoring_instance_id}\"}.mean() > 85"
severity = "WARNING"
destinations = [oci_ons_notification_topic.monitoring[0].id]
display_name = "homelab-edge-cpu-high"
is_enabled = true
pending_duration = "PT15M"
resolution = "1m"
alarm_summary = "OCI edge VM CPU utilization is above 85 percent"
body = "The Jeannie-managed edge VM has sustained high CPU utilization."
freeform_tags = local.base_tags
}
resource "oci_monitoring_alarm" "edge_unavailable" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled && local.edge_monitoring_instance_id != null && trimspace(local.edge_monitoring_instance_id) != "" ? 1 : 0
compartment_id = local.edge_monitoring_compartment_id
metric_compartment_id = local.edge_monitoring_compartment_id
namespace = "oci_computeagent"
query = "CpuUtilization[5m]{resourceId = \"${local.edge_monitoring_instance_id}\"}.absent()"
severity = "CRITICAL"
destinations = [oci_ons_notification_topic.monitoring[0].id]
display_name = "homelab-edge-unavailable"
is_enabled = true
pending_duration = "PT5M"
resolution = "1m"
alarm_summary = "OCI edge VM metrics are unavailable"
body = "The Jeannie-managed edge VM has stopped reporting OCI Compute Agent metrics."
freeform_tags = local.base_tags
}
resource "oci_monitoring_alarm" "email_cpu_high" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled && local.email_monitoring_instance_id != null && trimspace(local.email_monitoring_instance_id) != "" ? 1 : 0
compartment_id = local.email_monitoring_compartment_id
metric_compartment_id = local.email_monitoring_compartment_id
namespace = "oci_computeagent"
query = "CpuUtilization[5m]{resourceId = \"${local.email_monitoring_instance_id}\"}.mean() > 85"
severity = "WARNING"
destinations = [oci_ons_notification_topic.monitoring[0].id]
display_name = "homelab-email-cpu-high"
is_enabled = true
pending_duration = "PT15M"
resolution = "1m"
alarm_summary = "OCI email VM CPU utilization is above 85 percent"
body = "The Jeannie-managed email VM has sustained high CPU utilization."
freeform_tags = local.base_tags
}
resource "oci_monitoring_alarm" "email_unavailable" {
count = var.enabled && var.monitoring_enabled && var.monitoring_alarms_enabled && local.email_monitoring_instance_id != null && trimspace(local.email_monitoring_instance_id) != "" ? 1 : 0
compartment_id = local.email_monitoring_compartment_id
metric_compartment_id = local.email_monitoring_compartment_id
namespace = "oci_computeagent"
query = "CpuUtilization[5m]{resourceId = \"${local.email_monitoring_instance_id}\"}.absent()"
severity = "CRITICAL"
destinations = [oci_ons_notification_topic.monitoring[0].id]
display_name = "homelab-email-unavailable"
is_enabled = true
pending_duration = "PT5M"
resolution = "1m"
alarm_summary = "OCI email VM metrics are unavailable"
body = "The Jeannie-managed email VM has stopped reporting OCI Compute Agent metrics."
freeform_tags = local.base_tags
}

View File

@ -5,27 +5,13 @@ output "email_subnet_id" { value = local.email_subnet_id }
output "private_subnet_id" { value = try(oci_core_subnet.private[0].id, null) }
output "edge_instance_id" { value = try(oci_core_instance.edge[0].id, data.oci_core_instance.existing_edge[0].id, null) }
output "edge_public_ip" { value = try(oci_core_instance.edge[0].public_ip, data.oci_core_instance.existing_edge[0].public_ip, null) }
output "email_instance_id" { value = try(oci_core_instance.email[0].id, try(data.oci_core_instance.monitoring_email[0].id, null)) }
output "email_public_ip" { value = try(oci_core_instance.email[0].public_ip, try(data.oci_core_instance.monitoring_email[0].public_ip, null)) }
output "email_instance_id" { value = try(oci_core_instance.email[0].id, null) }
output "email_public_ip" { value = try(oci_core_instance.email[0].public_ip, null) }
output "bastion_id" { value = try(oci_bastion_bastion.homelab[0].id, var.bastion_existing_id, null) }
output "bastion_target_subnet_id" { value = try(oci_bastion_bastion.homelab[0].target_subnet_id, local.bastion_target_subnet_id, null) }
output "backup_bucket_id" { value = try(oci_objectstorage_bucket.homelab_backups[0].id, null) }
output "backup_bucket_name" { value = try(oci_objectstorage_bucket.homelab_backups[0].name, null) }
output "backup_bucket_namespace" { value = try(oci_objectstorage_bucket.homelab_backups[0].namespace, null) }
output "monitoring_topic_id" { value = try(oci_ons_notification_topic.monitoring[0].id, null) }
output "monitoring_email_subscription_id" { value = try(oci_ons_subscription.monitoring_email[0].id, null) }
output "monitoring_edge_alarm_ids" {
value = {
cpu_high = try(oci_monitoring_alarm.edge_cpu_high[0].id, null)
unavailable = try(oci_monitoring_alarm.edge_unavailable[0].id, null)
}
}
output "monitoring_email_alarm_ids" {
value = {
cpu_high = try(oci_monitoring_alarm.email_cpu_high[0].id, null)
unavailable = try(oci_monitoring_alarm.email_unavailable[0].id, null)
}
}
output "next_steps" {
value = [
"Set LAB_EDGE_HOST to edge_public_ip and run ./jeannie edge to configure the edge proxy.",
@ -33,6 +19,5 @@ output "next_steps" {
"Reserve the email public IP and request OCI reverse DNS/PTR before production mail.",
"Request OCI SMTP port 25 access; it is restricted by default for newer tenancies.",
"Add DNS A/AAAA, MX, SPF, DKIM, and DMARC records only after choosing the mail domain.",
"OCI VM CPU and availability alarms are delivered through the monitoring Notifications topic; confirm the email subscription if configured.",
]
}

View File

@ -130,36 +130,6 @@ variable "monitoring_cidr" {
default = ""
}
variable "monitoring_alarms_enabled" {
description = "Create OCI Monitoring alarms and a Notifications topic for the managed OCI VMs."
type = bool
default = true
}
variable "monitoring_topic_name" {
description = "OCI Notifications topic used by VM monitoring alarms."
type = string
default = "homelab-monitoring"
}
variable "monitoring_notification_email" {
description = "Optional email subscription for OCI VM alarms; OCI requires confirmation before delivery."
type = string
default = ""
}
variable "edge_monitoring_instance_id" {
description = "Persisted edge instance OCID used by OCI Monitoring alarms when the VM is adopted."
type = string
default = ""
}
variable "email_monitoring_instance_id" {
description = "Persisted email instance OCID used by OCI Monitoring alarms when the VM is adopted."
type = string
default = ""
}
variable "backup_bucket_enabled" {
description = "Create a private OCI Object Storage bucket for encrypted Jeannie backups."
type = bool

View File

@ -58,24 +58,6 @@
"targets": [{"expr": "ALERTS{alertstate=\"firing\"}", "legendFormat": "{{alertname}} {{instance}}", "refId": "A"}],
"title": "Firing Alerts",
"type": "table"
},
{
"datasource": {"type": "prometheus", "uid": "prometheus"},
"fieldConfig": {"defaults": {}, "overrides": []},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 24},
"id": 7,
"targets": [{"expr": "up{job=~\"oci-edge-node|oci-email-node|oci-edge-containers|rpi-node|jeannie-self-heal|traefik|jeannie-api\"}", "format": "table", "instant": true, "refId": "A"}],
"title": "Service and Exporter Status",
"type": "table"
},
{
"datasource": {"type": "prometheus", "uid": "prometheus"},
"fieldConfig": {"defaults": {"unit": "bytes", "min": 0}, "overrides": []},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 24},
"id": 8,
"targets": [{"expr": "sum by (name) (container_memory_working_set_bytes{container!=\"\",image!=\"\"})", "legendFormat": "{{name}}", "refId": "A"}],
"title": "Kubernetes Container Memory",
"type": "timeseries"
}
],
"refresh": "30s",
@ -83,7 +65,6 @@
"tags": ["homelab", "overview", "oci"],
"templating": {"list": []},
"time": {"from": "now-6h", "to": "now"},
"description": "Unified homelab view for OCI VMs, Raspberry Pi, Kubernetes containers, exporters, and Jeannie alerts. OCI-native VM alarms notify through the managed Notifications topic.",
"title": "Homelab Overview",
"uid": "homelab-overview",
"version": 1

View File

@ -29,7 +29,7 @@ var allowedCommands = map[string]bool{
"help": true, "up": true, "plan": true,
"cluster-profile": true, "rebuild-cluster": true, "stop-cluster": true,
"start-cluster": true, "cleanup-debian-k8s": true,
"shutdown": true, "start": true,
"shutdown": true,
"status": true, "capacity": true, "capacity-advisor": true,
"capacity-limits": true, "recover-plan": true, "gitops-status": true,
"gitops": true,

View File

@ -86,7 +86,6 @@ Cluster Lifecycle
stop-cluster Stop Kubernetes and worker VMs without destroy.
start-cluster Start Kubernetes and desired worker VMs.
shutdown {plan|apply --yes} Stop homelab services on every managed host; keep Jeannie API.
start {plan|apply} Start homelab services on every managed host.
cleanup-debian-k8s Remove old Debian kubeadm runtime after Pimox offload.
workers <list|tailnet|start|stop|restart|drain|uncordon|recreate-plan|rebalance|disk-status|disk-cleanup>
Manage Pimox/Kubernetes workers.
@ -254,10 +253,6 @@ case "${1:-}" in
record_change_journal "shutdown" "$@"
homelab_shutdown "${@:2}"
;;
start)
record_change_journal "start" "$@"
homelab_start "${@:2}"
;;
start-cluster)
record_change_journal "start-cluster" "$@"
start_cluster

View File

@ -763,44 +763,6 @@ else
fi"
}
start_remote_compose_stack() {
local label="$1"
local target="$2"
local install_dir="$3"
local key_path="${4:-}"
local ssh_args=(-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new)
[[ -n "${key_path}" ]] && ssh_args+=(-i "${key_path}")
echo "--> Starting ${label} services on ${target} (${install_dir})..."
ssh "${ssh_args[@]}" "${target}" "
set -eu
if [ -f '${install_dir}/docker-compose.yml' ] || [ -f '${install_dir}/compose.yml' ]; then
cd '${install_dir}'
if sudo docker compose version >/dev/null 2>&1; then
sudo docker compose start || sudo docker compose up -d --remove-orphans
elif command -v docker-compose >/dev/null 2>&1; then
sudo docker-compose start || sudo docker-compose up -d --remove-orphans
else
echo 'Docker Compose is unavailable.' >&2
exit 1
fi
else
echo '${install_dir}/docker-compose.yml not found.' >&2
exit 1
fi"
}
start_bastion_compose_stack() {
local label="$1" bastion_id="$2" instance_id="$3" user="$4" public_key="$5" private_key="$6" install_dir="$7"
[[ -n "${bastion_id}" && -n "${instance_id}" ]] || {
echo "${label} Bastion target is not configured; cannot start through the private path." >&2
return 1
}
echo "--> Starting ${label} services through OCI Bastion (${instance_id})..."
"${REPO_ROOT}/scripts/oci-bastion-ssh" --command "cd '${install_dir}' && (sudo docker compose start || sudo docker compose up -d --remove-orphans)" \
"${bastion_id}" "${instance_id}" "${user}" "${public_key}" "${private_key}"
}
shutdown_rpi_services() {
local rpi_host="${LAB_RPI_HOST:-${LAB_RASPBERRY_HOST:-192.168.100.89}}"
local rpi_user="${LAB_RPI_USER:-${LAB_RASPBERRY_USER:-jv}}"
@ -865,118 +827,6 @@ shutdown_debian_services() {
fi
}
start_debian_services() {
echo "--> Starting Debian homelab services (jeannie-server is already preserved)..."
sudo systemctl start docker 2>/dev/null || true
sudo systemctl start \
jeannie-eventd.service \
jeannie-temporal-worker.service \
homelab-edge-traefik-route.service \
homelab-pimox-registry-forward.service \
homelab-gitea-runner.service \
homelab-gitea-backup.service \
homelab-gitea-restore-drill.service \
homelab-profile-backup.service \
2>/dev/null || true
local containers
containers="$(sudo docker ps -aq 2>/dev/null || true)"
if [[ -n "${containers}" ]]; then
echo "Starting Debian Docker container(s)..."
printf '%s\n' "${containers}" | xargs -r sudo docker start >/dev/null
fi
}
start_rpi_services() {
local rpi_host="${LAB_RPI_HOST:-${LAB_RASPBERRY_HOST:-192.168.100.89}}"
local rpi_user="${LAB_RPI_USER:-${LAB_RASPBERRY_USER:-jv}}"
local rpi_key="${LAB_RPI_SSH_KEY_PATH:-${LAB_RASPBERRY_SSH_KEY_PATH:-${HOME}/.ssh/id_ed25519}}"
local install_dir="${LAB_RPI_SERVICES_INSTALL_DIR:-/opt/homelab-rpi-services}"
start_remote_compose_stack "RPi4" "${rpi_user}@${rpi_host}" "${install_dir}" "${rpi_key}"
}
start_oci_edge_services() {
local edge_host="${LAB_EDGE_HOST:-${LAB_OCI_EDGE_PUBLIC_IP:-}}"
local edge_user="${LAB_EDGE_USER:-ubuntu}"
local edge_key="${LAB_EDGE_SSH_KEY_PATH:-${LAB_OCI_SSH_PRIVATE_KEY:-${HOME}/.ssh/id_ed25519}}"
local install_dir="${LAB_EDGE_INSTALL_DIR:-/opt/homelab-edge}"
if truthy "${LAB_OCI_BASTION_ENABLED:-true}" && [[ -n "${LAB_OCI_BASTION_ID:-}" && -n "${LAB_OCI_EDGE_INSTANCE_ID:-}" ]]; then
start_bastion_compose_stack "OCI edge" "${LAB_OCI_BASTION_ID}" "${LAB_OCI_EDGE_INSTANCE_ID}" "${edge_user}" "${edge_key}.pub" "${edge_key}" "${install_dir}"
else
[[ -n "${edge_host}" ]] || { echo "OCI edge host is not configured." >&2; return 1; }
start_remote_compose_stack "OCI edge" "${edge_user}@${edge_host}" "${install_dir}" "${edge_key}"
fi
}
start_oci_email_services() {
local email_host="${LAB_EMAIL_PUBLIC_IP:-${LAB_OCI_EMAIL_PUBLIC_IP:-}}"
local email_user="${LAB_EMAIL_SSH_USER:-ubuntu}"
local email_key="${LAB_EMAIL_SSH_PRIVATE_KEY:-${HOME}/.ssh/id_ed25519}"
if [[ -z "${email_host}" ]]; then
email_host="$(tofu -chdir="${REPO_ROOT}/bootstrap/oci" output -raw email_public_ip 2>/dev/null || true)"
fi
[[ -n "${email_host}" && "${email_host}" != "null" ]] || { echo "OCI email host is not configured; skipping mail VM."; return 0; }
if truthy "${LAB_OCI_BASTION_ENABLED:-true}" && [[ -n "${LAB_OCI_BASTION_ID:-}" && -n "${LAB_OCI_EMAIL_INSTANCE_ID:-}" ]]; then
echo "--> Starting OCI email services through OCI Bastion..."
"${REPO_ROOT}/scripts/oci-bastion-ssh" --command "sudo systemctl start postfix dovecot fail2ban prometheus-node-exporter 2>/dev/null || true" \
"${LAB_OCI_BASTION_ID}" "${LAB_OCI_EMAIL_INSTANCE_ID}" "${email_user}" "${email_key}.pub" "${email_key}"
else
echo "--> Starting OCI email services on ${email_user}@${email_host}..."
ssh -i "${email_key}" -o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new \
"${email_user}@${email_host}" \
"sudo systemctl start postfix dovecot fail2ban prometheus-node-exporter 2>/dev/null || true"
fi
}
homelab_start() {
local action="${1:-plan}"
local failures=0
case "${action}" in
plan)
cat <<'EOF'
Homelab startup plan
====================
Start Debian services and containers, Kubernetes/Pimox, RPi4 services,
OCI edge services, and OCI email services. Existing disks and configuration
are preserved; already-running services are left unchanged.
Run ./jeannie start apply to execute this plan.
EOF
;;
apply)
require_debian_server "start"
oci_foundation_load_config
if truthy "${LAB_OCI_BASTION_ENABLED:-true}" && [[ -n "${LAB_OCI_TENANCY_ID:-}" ]]; then
local discovered_bastion discovered_edge discovered_email
discovered_bastion="$(oci_discover_active_bastion_id "${LAB_OCI_COMPARTMENT_ID:-${LAB_OCI_TENANCY_ID}}" "${LAB_OCI_BASTION_NAME:-homelab-bastion}" || true)"
[[ -n "${discovered_bastion}" ]] && LAB_OCI_BASTION_ID="${discovered_bastion}"
discovered_edge="$(oci_discover_active_instance_id "${LAB_OCI_EDGE_DISPLAY_NAME:-homelab-edge}" "${LAB_OCI_COMPARTMENT_ID:-${LAB_OCI_TENANCY_ID}}" || true)"
[[ -n "${discovered_edge}" ]] && LAB_OCI_EDGE_INSTANCE_ID="${discovered_edge}"
if [[ -n "${LAB_OCI_EMAIL_COMPARTMENT_ID:-}" ]]; then
discovered_email="$(oci_discover_active_instance_id "${LAB_OCI_EMAIL_DISPLAY_NAME:-homelab-mail}" "${LAB_OCI_EMAIL_COMPARTMENT_ID}" || true)"
[[ -n "${discovered_email}" ]] && LAB_OCI_EMAIL_INSTANCE_ID="${discovered_email}"
fi
oci_foundation_save_config
fi
echo "Starting all managed homelab services..."
start_debian_services || failures=$((failures + 1))
start_cluster || failures=$((failures + 1))
start_rpi_services || failures=$((failures + 1))
start_oci_edge_services || failures=$((failures + 1))
start_oci_email_services || failures=$((failures + 1))
if systemctl is-active --quiet jeannie-server.service 2>/dev/null; then
echo "PASS jeannie-server.service is active."
else
echo "FAIL jeannie-server.service is not active." >&2
failures=$((failures + 1))
fi
((failures == 0)) || { echo "Homelab startup finished with ${failures} failure(s)." >&2; return 1; }
echo "Homelab services started."
;;
--help|help) echo "Usage: ./jeannie start {plan|apply}" ;;
*) echo "Usage: ./jeannie start {plan|apply}" >&2; return 2 ;;
esac
}
homelab_shutdown() {
local action="${1:-plan}"
local failures=0
@ -1065,7 +915,6 @@ start_cluster() {
else
start_local_kubernetes_services
start_pimox_worker_vms
wait_for_cluster_ssh_targets
for target in "${CLUSTER_WORKER_TARGETS[@]}"; do
start_remote_kubernetes_services "${target}"
done
@ -3752,10 +3601,10 @@ oci_foundation_config_names=(
LAB_OCI_OPEN_MAIL_PORTS LAB_OCI_AUTO_CONFIGURE_EDGE LAB_EDGE_HOST
LAB_OCI_AUTO_CONFIGURE_EMAIL LAB_OCI_AUTO_UPDATE_DUCKDNS LAB_DUCKDNS_DOMAINS
LAB_OCI_FOUNDATION_STATE_FILE
LAB_OCI_MONITORING_ENABLED LAB_OCI_MONITORING_CIDR LAB_OCI_MONITORING_ALARMS_ENABLED LAB_OCI_MONITORING_TOPIC_NAME LAB_OCI_MONITORING_TOPIC_ID LAB_OCI_MONITORING_NOTIFICATION_EMAIL
LAB_OCI_MONITORING_ENABLED LAB_OCI_MONITORING_CIDR
LAB_OCI_BACKUP_BUCKET_ENABLED LAB_OCI_BACKUP_BUCKET LAB_OCI_BACKUP_BUCKET_NAME LAB_OCI_BACKUP_BUCKET_NAMESPACE LAB_OCI_BACKUP_BUCKET_ID
LAB_OCI_BASTION_ENABLED LAB_OCI_BASTION_NAME LAB_OCI_BASTION_TARGET_SUBNET_ID LAB_OCI_BASTION_SSH_SOURCE_CIDR
LAB_OCI_BASTION_CLIENT_CIDRS_JSON LAB_OCI_BASTION_MAX_SESSION_TTL LAB_OCI_BASTION_ID LAB_OCI_EDGE_COMPARTMENT_ID LAB_OCI_EDGE_INSTANCE_ID LAB_OCI_EMAIL_INSTANCE_ID LAB_OCI_EDGE_INSTANCE_MANAGED
LAB_OCI_BASTION_CLIENT_CIDRS_JSON LAB_OCI_BASTION_MAX_SESSION_TTL LAB_OCI_BASTION_ID LAB_OCI_EDGE_COMPARTMENT_ID LAB_OCI_EDGE_INSTANCE_ID LAB_OCI_EDGE_INSTANCE_MANAGED
LAB_EMAIL_PUBLIC_IP LAB_OCI_EDGE_METRICS_TARGET LAB_OCI_EMAIL_METRICS_TARGET
)
@ -4113,7 +3962,6 @@ oci_foundation_manage() {
local discovered_backup_bucket_name
local discovered_backup_bucket_namespace
local discovered_backup_bucket_id
local discovered_monitoring_topic_id
local discovered_edge_instance_id
local post_apply_failures=0
discovered_edge_ip="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw edge_public_ip 2>/dev/null || true)"
@ -4122,10 +3970,7 @@ oci_foundation_manage() {
discovered_backup_bucket_name="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw backup_bucket_name 2>/dev/null || true)"
discovered_backup_bucket_namespace="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw backup_bucket_namespace 2>/dev/null || true)"
discovered_backup_bucket_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw backup_bucket_id 2>/dev/null || true)"
discovered_monitoring_topic_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw monitoring_topic_id 2>/dev/null || true)"
discovered_edge_instance_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw edge_instance_id 2>/dev/null || true)"
local discovered_email_instance_id
discovered_email_instance_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw email_instance_id 2>/dev/null || true)"
if [[ "${discovered_bastion_id}" == ocid1.bastion.* ]]; then
export LAB_OCI_BASTION_ID="${discovered_bastion_id}"
fi
@ -4137,9 +3982,6 @@ oci_foundation_manage() {
export LAB_OCI_EDGE_INSTANCE_MANAGED=false
fi
fi
if [[ "${discovered_email_instance_id}" == ocid1.instance.* ]]; then
export LAB_OCI_EMAIL_INSTANCE_ID="${discovered_email_instance_id}"
fi
if [[ -n "${discovered_backup_bucket_name}" && "${discovered_backup_bucket_name}" != "null" ]]; then
export LAB_OCI_BACKUP_BUCKET="${discovered_backup_bucket_name}"
export LAB_OCI_BACKUP_BUCKET_NAME="${discovered_backup_bucket_name}"
@ -4150,14 +3992,13 @@ oci_foundation_manage() {
if [[ -n "${discovered_backup_bucket_id}" && "${discovered_backup_bucket_id}" != "null" ]]; then
export LAB_OCI_BACKUP_BUCKET_ID="${discovered_backup_bucket_id}"
fi
if [[ "${discovered_monitoring_topic_id}" == ocid1.onstopic.* ]]; then
export LAB_OCI_MONITORING_TOPIC_ID="${discovered_monitoring_topic_id}"
fi
if truthy "${LAB_OCI_BASTION_ENABLED:-true}"; then
if [[ "${discovered_edge_instance_id}" == ocid1.instance.* ]]; then
printf 'Enabling OCI Bastion plugin on edge instance...\n'
oci_enable_bastion_plugin "${discovered_edge_instance_id}" || post_apply_failures=$((post_apply_failures + 1))
fi
local discovered_email_instance_id
discovered_email_instance_id="$(tofu -chdir="${stack}" output "${tofu_state_args[@]}" -raw email_instance_id 2>/dev/null || true)"
if [[ "${discovered_email_instance_id}" == ocid1.instance.* ]]; then
printf 'Enabling OCI Bastion plugin on email instance...\n'
oci_enable_bastion_plugin "${discovered_email_instance_id}" || post_apply_failures=$((post_apply_failures + 1))
@ -4272,36 +4113,6 @@ oci_cli_resolve() {
fi
}
oci_discover_active_instance_id() {
local display_name="$1" compartment_id="$2" oci_bin payload
oci_bin="$(oci_cli_resolve)" || return 1
payload="$("${oci_bin}" compute instance list --compartment-id "${compartment_id}" --all --output json 2>/dev/null || true)"
[[ -n "${payload}" ]] || return 1
OCI_DISCOVERY_JSON="${payload}" python3 - "${display_name}" <<'PY'
import json, os, sys
name = sys.argv[1]
for item in json.loads(os.environ["OCI_DISCOVERY_JSON"]).get("data", []):
if item.get("display-name") == name and item.get("lifecycle-state") == "RUNNING":
print(item.get("id", ""))
break
PY
}
oci_discover_active_bastion_id() {
local compartment_id="$1" bastion_name="$2" oci_bin payload
oci_bin="$(oci_cli_resolve)" || return 1
payload="$("${oci_bin}" bastion bastion list --compartment-id "${compartment_id}" --all --output json 2>/dev/null || true)"
[[ -n "${payload}" ]] || return 1
OCI_DISCOVERY_JSON="${payload}" python3 - "${bastion_name}" <<'PY'
import json, os, sys
name = sys.argv[1]
for item in json.loads(os.environ["OCI_DISCOVERY_JSON"]).get("data", []):
if item.get("name") == name and item.get("lifecycle-state") == "ACTIVE":
print(item.get("id", ""))
break
PY
}
oci_status() {
require_debian_server "oci status"
oci_foundation_load_config

View File

@ -372,11 +372,6 @@ export_oci_foundation_tf_vars() {
export_if_unset TF_VAR_admin_cidr "${LAB_OCI_ADMIN_CIDR:-}"
export_if_unset TF_VAR_monitoring_enabled "${LAB_OCI_MONITORING_ENABLED:-}"
export_if_unset TF_VAR_monitoring_cidr "${LAB_OCI_MONITORING_CIDR:-${LAB_OCI_ADMIN_CIDR:-}}"
export_if_unset TF_VAR_monitoring_alarms_enabled "${LAB_OCI_MONITORING_ALARMS_ENABLED:-}"
export_if_unset TF_VAR_monitoring_topic_name "${LAB_OCI_MONITORING_TOPIC_NAME:-}"
export_if_unset TF_VAR_monitoring_notification_email "${LAB_OCI_MONITORING_NOTIFICATION_EMAIL:-}"
export_if_unset TF_VAR_edge_monitoring_instance_id "${LAB_OCI_EDGE_INSTANCE_ID:-}"
export_if_unset TF_VAR_email_monitoring_instance_id "${LAB_OCI_EMAIL_INSTANCE_ID:-}"
export_if_unset TF_VAR_backup_bucket_enabled "${LAB_OCI_BACKUP_BUCKET_ENABLED:-}"
export_if_unset TF_VAR_backup_bucket_name "${LAB_OCI_BACKUP_BUCKET_NAME:-${LAB_OCI_BACKUP_BUCKET:-}}"
export_if_unset TF_VAR_backup_bucket_namespace "${LAB_OCI_BACKUP_BUCKET_NAMESPACE:-}"

View File

@ -4,7 +4,6 @@ set -euo pipefail
print_command=false
public_key_material=""
private_key_override=""
remote_command=""
if [[ "${1:-}" == "ssh" ]]; then
shift
fi
@ -13,7 +12,6 @@ while (($# > 0)); do
--print-command) print_command=true; shift ;;
--public-key) public_key_material="${2:-}"; shift 2 ;;
--private-key-path) private_key_override="${2:-}"; shift 2 ;;
--command) remote_command="${2:-}"; shift 2 ;;
--) shift; break ;;
*) break ;;
esac
@ -74,9 +72,6 @@ ssh_command="$("${oci_bin}" bastion session get \
--query 'data."ssh-metadata".command' \
--raw-output)"
ssh_command="${ssh_command//<privateKey>/${private_key}}"
if [[ -n "${remote_command}" ]]; then
ssh_command+=" -- ${remote_command}"
fi
if [[ "${print_command}" == true ]]; then
printf 'session_id=%s\n' "${session_id}"
printf 'ssh_command=%s\n' "${ssh_command}"