fix: enable OCI Bastion agent plugin

This commit is contained in:
juvenal.diaz 2026-10-27 08:14:09 -06:00
parent 36730361d5
commit 31949a55e9
2 changed files with 52 additions and 0 deletions

View File

@ -361,6 +361,14 @@ resource "oci_core_instance" "edge" {
ocpus = var.edge_ocpus
memory_in_gbs = var.edge_memory_in_gbs
}
agent_config {
is_management_disabled = false
is_monitoring_disabled = false
plugins_config {
name = "Bastion"
desired_state = "ENABLED"
}
}
source_details {
source_type = "image"
source_id = var.edge_image_id
@ -386,6 +394,14 @@ resource "oci_core_instance" "email" {
ocpus = var.email_ocpus
memory_in_gbs = var.email_memory_in_gbs
}
agent_config {
is_management_disabled = false
is_monitoring_disabled = false
plugins_config {
name = "Bastion"
desired_state = "ENABLED"
}
}
source_details {
source_type = "image"
source_id = var.email_image_id

View File

@ -3811,6 +3811,18 @@ oci_foundation_manage() {
if [[ -n "${discovered_edge_instance_id}" && "${discovered_edge_instance_id}" != "null" ]]; then
export LAB_OCI_EDGE_INSTANCE_ID="${discovered_edge_instance_id}"
fi
if truthy "${LAB_OCI_BASTION_ENABLED:-true}"; then
if [[ -n "${discovered_edge_instance_id}" && "${discovered_edge_instance_id}" != "null" ]]; 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 [[ -n "${discovered_email_instance_id}" && "${discovered_email_instance_id}" != "null" ]]; 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))
fi
fi
if [[ -n "${discovered_edge_ip}" && "${discovered_edge_ip}" != "null" ]]; then
export LAB_EDGE_HOST="${discovered_edge_ip}"
export TF_VAR_edge_host="${discovered_edge_ip}"
@ -3876,6 +3888,30 @@ oci_bastion_ssh() {
"${REPO_ROOT}/scripts/oci-bastion-ssh" "$@"
}
oci_enable_bastion_plugin() {
local instance_id="${1:-}"
local oci_bin agent_config
[[ -n "${instance_id}" ]] || return 0
oci_bin="$(oci_cli_resolve)" || return 1
agent_config="$(mktemp)"
cat >"${agent_config}" <<'JSON'
{
"pluginsConfig": [
{
"desiredState": "ENABLED",
"name": "Bastion"
}
]
}
JSON
if ! "${oci_bin}" compute instance update --instance-id "${instance_id}" \
--agent-config "file://${agent_config}" --force >/dev/null; then
rm -f "${agent_config}"
return 1
fi
rm -f "${agent_config}"
}
oci_cli_resolve() {
if command -v oci >/dev/null 2>&1; then
command -v oci