Skip to content

Commit 480e757

Browse files
skommalaabhijit-paranjpetelakeroberto-sanchez-herreraPM-Darshan
authored
Development (#322)
merge from development to main --------- Co-authored-by: Abhijit Paranjpe <[email protected]> Co-authored-by: telake <[email protected]> Co-authored-by: Roberto Sanchez Herrera <[email protected]> Co-authored-by: P M Darshan <[email protected]> Co-authored-by: C R Aniruddh Srivatsa <[email protected]> Co-authored-by: Mahuwa Barman <[email protected]> Co-authored-by: Chintamani Bhat <[email protected]> Co-authored-by: Sarada Kommalapati <[email protected]> Co-authored-by: Adrian Padilla Duarte <[email protected]> Co-authored-by: Mahuwa-Barman <[email protected]> Co-authored-by: srjanaki <[email protected]> Co-authored-by: ManviGupta-prog <[email protected]> Co-authored-by: Ananya Tripathi <[email protected]>
1 parent ac1bd3c commit 480e757

File tree

12 files changed

+46
-13
lines changed

12 files changed

+46
-13
lines changed

terraform/locals.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ locals {
196196
select_existing_profile = var.select_existing_profile
197197
create_profile = (local.enable_osmh && !local.select_existing_profile) ? true : false
198198
profile_ocid = local.select_existing_profile ? var.profile_ocid : ""
199-
profile_compartment_id = var.profile_compartment_id
200-
profile_name = var.profile_name
199+
profile_compartment_id = var.profile_compartment_id == "" ? var.compartment_ocid : var.profile_compartment_id
200+
profile_name = var.profile_name == "" ? format("%s_profile", local.service_name_prefix) : var.profile_name
201+
201202

202203
# Secured Production Mode
203204
preserve_boot_properties = var.configure_secure_mode ? var.preserve_boot_properties : true

terraform/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ module "policies" {
239239
apm_domain_compartment_id = local.apm_domain_compartment_id
240240
use_autoscaling = var.use_autoscaling
241241
enable_osmh = var.enable_osmh
242+
profile_compartment_id = var.profile_compartment_id
243+
242244
ocir_auth_token_id = var.ocir_auth_token_id
243245
add_fss = var.add_fss
244246
add_load_balancer = local.add_load_balancer
@@ -484,6 +486,9 @@ module "validators" {
484486
wls_secondary_admin_password_id = local.wls_secondary_admin_password_id
485487
administration_port = var.administration_port
486488
ms_administration_port = var.ms_administration_port
489+
490+
profile_ocid = local.profile_ocid
491+
select_existing_profile = local.select_existing_profile
487492
}
488493

489494
module "fss" {
@@ -593,7 +598,7 @@ module "observability-osmh"{
593598
source = "./modules/observability/osmh"
594599
count = local.create_profile ? 1 : 0
595600
tenancy_id = var.tenancy_ocid
596-
display_name = var.profile_name
601+
display_name = local.profile_name
597602
compartment_id = local.profile_compartment_id
598603
}
599604

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
terraform {
5+
required_providers {
6+
oci = {
7+
source = "oracle/oci"
8+
}
9+
}
10+
}

terraform/modules/policies/locals.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ locals {
5353
plugin_policy_statement = compact([local.plugin_policy_statement1, local.plugin_policy_statement2])
5454

5555
# Policies required for enabling the OSMH plugin
56-
osmh_policy_statement1 = var.enable_osmh? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to manage osmh-family in tenancy" : ""
57-
osmh_policy_statement2 = var.enable_osmh? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to {OSMH_MANAGED_INSTANCE_ACCESS} in tenancy where request.principal.id = target.managed-instance.id" : ""
58-
osmh_policy_statement = compact([local.osmh_policy_statement1, local.osmh_policy_statement2])
56+
osmh_policy_statement1 = var.enable_osmh? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to manage osmh-family in compartment id ${var.compartment_id}" : ""
57+
osmh_policy_statement2 = var.enable_osmh? var.profile_compartment_id != var.compartment_id? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to manage osmh-family in compartment id ${var.profile_compartment_id}" : "" : ""
58+
osmh_policy_statement3 = var.enable_osmh? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to {OSMH_MANAGED_INSTANCE_ACCESS} in tenancy where request.principal.id = target.managed-instance.id" : ""
59+
osmh_policy_statement4 = var.enable_osmh? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to {MGMT_AGENT_DEPLOY_PLUGIN_CREATE, MGMT_AGENT_INSPECT, MGMT_AGENT_READ} in compartment id ${var.compartment_id}" : ""
60+
osmh_policy_statement = compact([local.osmh_policy_statement1, local.osmh_policy_statement2, local.osmh_policy_statement3, local.osmh_policy_statement4])
61+
5962

6063
#Policies for WLS instance principal dynamic group
6164
autoscaling_statement1 = var.use_autoscaling ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to use repos in tenancy" : ""

terraform/modules/policies/variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ variable "wls_secondary_admin_password_id" {
224224
description = "The OCID of the vault secret with the password for secondary WebLogic administration user"
225225
}
226226
variable "enable_osmh" {
227-
type = bool
227+
type = bool
228228
description = "Indicating that OSMH is enabled"
229229
}
230+
variable "profile_compartment_id"{
231+
type = string
232+
description = "The compartment Id to create the profile"
233+
}
234+
230235

terraform/modules/validators/validators.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@ locals {
8484
invalid_jrf_12c_secure_mode = var.configure_secure_mode && local.is12cVersion && (var.is_oci_db || var.is_atp_db || trimspace(var.oci_db_connection_string) != "")
8585
invalid_jrf_12c_secure_mode_msg = "WLSC-ERROR: JRF domain is not supported for FMW 12c version in secured production mode."
8686
validate_jrf_12c_secure_mode = local.invalid_jrf_12c_secure_mode ? local.validators_msg_map[local.invalid_jrf_12c_secure_mode_msg] : ""
87+
88+
missing_profile_id_msg = "WLSC-ERROR: The value for profile id is required if existing profile is used for OSMH"
89+
validate_profile_id = (var.select_existing_profile && var.profile_ocid == "" ? local.validators_msg_map[local.missing_profile_id_msg] : null)
8790
}

terraform/modules/validators/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,11 @@ variable "ms_administration_port" {
564564
type = number
565565
description = "The administration port for managed servers to configure a secure WebLogic domain"
566566
}
567+
variable "select_existing_profile"{
568+
type = bool
569+
description = "Set to true to use an existing profile"
570+
}
571+
variable "profile_ocid"{
572+
type = string
573+
description = "The ocid of the profile used for OSMH registration."
574+
}

terraform/schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ groupings:
105105

106106
- title: "OS Management Hub Profile"
107107
variables:
108+
- ${select_existing_profile}
108109
- ${profile_compartment_id}
109110
- ${profile_name}
110-
- ${select_existing_profile}
111111
- ${profile_ocid}
112112

113113
- title: "Resource Manager Private Endpoint"

terraform/schema_14110.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ groupings:
7878

7979
- title: "OS Management Hub Profile"
8080
variables:
81+
- ${select_existing_profile}
8182
- ${profile_compartment_id}
8283
- ${profile_name}
83-
- ${select_existing_profile}
8484
- ${profile_ocid}
8585

8686
- title: "Resource Manager Private Endpoint"

terraform/schema_14120.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ groupings:
106106

107107
- title: "OS Management Hub Profile"
108108
variables:
109+
- ${select_existing_profile}
109110
- ${profile_compartment_id}
110111
- ${profile_name}
111-
- ${select_existing_profile}
112112
- ${profile_ocid}
113113

114114
- title: "Resource Manager Private Endpoint"

0 commit comments

Comments
 (0)