oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
758 stars 680 forks source link

ODI classic provisioning via terraform #2082

Open sivad1648 opened 7 months ago

sivad1648 commented 7 months ago

Community Note

Terraform Version and Provider Version

Terraform v1.6.2 Provider Version 5.27.0

Affected Resource(s)

Oracle Data Integrator Classic (oci_core_instance)

Terraform Configuration Files


#cloud-config-template

runcmd:
  # Enable and bring up vnc  
  - echo ${odi_vnc_password} | vncpasswd -f > /home/oracle/.vnc/passwd
  - chmod 0600 /home/oracle/.vnc/passwd  

  - chmod 0766 /home/oracle/.Xauthority
  - su opc
  - sudo cp /home/opc/.ssh/authorized_keys /home/oracle/.ssh/authorized_keys
  - sudo chown oracle:oracle /home/oracle/.ssh/authorized_keys
  - sudo systemctl enable oraclevncodi.service
  - sudo systemctl start oraclevncodi.service
  - sudo chmod +rwx /usr/share/applications/odi.desktop
  - sudo sed -i "s/ODI Studio/${studio_name}/g" /usr/share/applications/odi.desktop
  - sudo cp /usr/share/applications/odi.desktop /home/opc/Desktop
  - sudo chown opc:opc /home/opc/Desktop/odi.desktop
  - chmod +rwx /home/opc/Desktop/odi.desktop
  - sudo cp /usr/share/applications/odi.desktop /home/oracle/Desktop
  - sudo chown oracle:oracle /home/oracle/Desktop/odi.desktop
  - sudo chmod +rwx /home/oracle/Desktop/odi.desktop
  - sudo cp /usr/share/applications/adpregister.desktop /home/oracle/Desktop
  - sudo chown oracle:oracle /home/oracle/Desktop/adpregister.desktop
  - sudo chmod +rwx /home/oracle/Desktop/adpregister.desktop

  # Create the adw properties file

  - echo "[config]" > /u01/oracle/odi-setup.properties   
  - echo " " >> /u01/oracle/odi-setup.properties   
  - echo "mp_stack_mode=${studio_mode}" >> /u01/oracle/odi-setup.properties   
  - echo "dbTech=${db_tech}" >> /u01/oracle/odi-setup.properties 
  - echo "adwInstanceOcId=${adw_instance}" >> /u01/oracle/odi-setup.properties
  - echo "adwInstancePassword="'${adw_password}' >> /u01/oracle/odi-setup.properties
  - echo "odiSchemaPrefix=${odi_schema_prefix}" >> /u01/oracle/odi-setup.properties
  - echo "odiSchemaPassword="'${odi_schema_password}' >> /u01/oracle/odi-setup.properties
  - echo "odiSupervisorPassword="'${odi_password}' >> /u01/oracle/odi-setup.properties
  - echo "rcuCreationMode=${adw_creation_mode}" >> /u01/oracle/odi-setup.properties
  - echo "odiSchemaUser=${odi_schema_prefix}_ODI_REPO" >> /u01/oracle/odi-setup.properties 
  - echo "register_odi_adp=${register_repository}" >> /u01/oracle/odi-setup.properties

  - echo export JAVA_HOME=/u01/oracle/jdk1.8.0_391 >> /home/oracle/.bashrc
  - echo export PATH=/u01/oracle/jdk1.8.0_391/bin:$PATH >> /home/oracle/.bashrc 
  - echo export APP_LOGS=/u01/oracle/mwh/app_logs >> /home/oracle/.bashrc 
  - echo export MW_HOME=/u01/oracle/mwh >> /home/oracle/.bashrc

  - echo masterReposDriver=oracle.jdbc.OracleDriver >> /u01/oracle/repository.properties
  - echo masterReposUser=${odi_schema_prefix}_ODI_REPO >> /u01/oracle/repository.properties
  - echo workReposName=WORKREP >> /u01/oracle/repository.properties

  - mv /u01/oracle/odi-setup.properties /u01/oracle/mwh/odi/common/scripts
  - mv /u01/oracle/repository.properties /u01/oracle/mwh/odi/common/scripts
  - chown oracle:oracle /u01/oracle/mwh/odi/common/scripts/repository.properties
  - chown oracle:oracle /u01/oracle/mwh/odi/common/scripts/odi-setup.properties

  - echo "export JAVA_HOME=/home/oracle/jdk1.8.0_391" > /u01/oracle/configureRepo.sh
  - echo "export PATH=/home/oracle/jdk1.8.0_391/bin:$PATH" >> /u01/oracle/configureRepo.sh
  - echo "if !(${show_adp_desktop}) " >> /u01/oracle/configureRepo.sh 
  - echo "then " >> /u01/oracle/configureRepo.sh
  - echo "rm /home/oracle/Desktop/adpregister.desktop " >> /u01/oracle/configureRepo.sh
  - echo "fi" >>  /u01/oracle/configureRepo.sh  
  - echo "if ${embedded_db}" >> /u01/oracle/configureRepo.sh 
  - echo "then " >> /u01/oracle/configureRepo.sh
  - echo "echo mp_stack_mode="${studio_mode} "> /u01/oracle/mwh/odi/common/scripts/odi-setup.properties; echo dbTech="${db_tech} ">> /u01/oracle/mwh/odi/common/scripts/odi-setup.properties;" >> /u01/oracle/configureRepo.sh
  - echo "fi" >>  /u01/oracle/configureRepo.sh
  - echo "python odiMPConfiguration.py" >> /u01/oracle/configureRepo.sh
  - echo "rm -f /u01/oracle/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz /u01/oracle/mysql-connector-python-2.1.8.zip" >> /u01/oracle/configureRepo.sh    
  - echo "echo 'Finished MP configuration' " >> /u01/oracle/configureRepo.sh
  - echo "echo 'Going to start Apps' " >> /u01/oracle/configureRepo.sh
  - echo "python manageOdiApps.py start" >> /u01/oracle/configureRepo.sh
  - mv /u01/oracle/configureRepo.sh /u01/oracle/mwh/odi/common/scripts
  - chown oracle:oracle /u01/oracle/mwh/odi/common/scripts/configureRepo.sh
  - chmod +rwx /u01/oracle/mwh/odi/common/scripts/configureRepo.sh
  - chmod +rwx /u01/oracle/mwh/odi/common/scripts/configureADBInstances.sh
  - cd /u01/oracle/mwh/odi/common/scripts 
  - sudo su
  - su oracle -c "export MW_HOME=/u01/oracle/mwh; export APP_LOGS=/u01/oracle/mwh/app_logs; export JAVA_HOME=/u01/oracle/jdk1.8.0_391; export PATH=/u01/oracle/jdk1.8.0_391/bin:$PATH; ./configureRepo.sh" > /u01/oracle/logs/odiConfigure.log      
  - sudo systemctl start mysqlodi.service
  - sudo systemctl start manageappsodi.service  

final_message: "The system is finally up, after $UPTIME seconds"

variable "marketplace_source_images" {
  type = map(object({
    ocid                  = string
    is_pricing_associated = bool
  compatible_shapes = set(string) }))
  default = {
    main_mktpl_image = {
      ocid                  = "ocid1.image.oc1..aaaaaaaaxesj6sgtl35e36l66kwb6fvoskheqzur6hupg5ecd4ksfjf6lljq"
      is_pricing_associated = true
      compatible_shapes     = []
  } }
}

#Get Image Agreement
resource "oci_core_app_catalog_listing_resource_version_agreement" "mp_image_agreement" {
  count                    = var.use_marketplace_image ? 1 : 0
  listing_id               = var.mp_listing_id
  listing_resource_version = var.mp_listing_resource_version
}

#Accept Terms and Subscribe to the image, placing the image in a particular compartment
resource "oci_core_app_catalog_subscription" "mp_image_subscription" {
  count                    = var.use_marketplace_image ? 1 : 0
  compartment_id           = var.compartment_id
  eula_link                = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].eula_link
  listing_id               = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].listing_id
  listing_resource_version = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].listing_resource_version
  oracle_terms_of_use_link = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].oracle_terms_of_use_link
  signature                = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].signature
  time_retrieved           = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].time_retrieved
  timeouts {
    create = "20m"
  }
}

# Gets the partner image subscription
data "oci_core_app_catalog_subscriptions" "mp_image_subscription" {
  count = var.use_marketplace_image ? 1 : 0

  #Required
  compartment_id = var.compartment_id

  #Optional
  listing_id = var.mp_listing_id

  filter {
    name   = "listing_resource_version"
    values = [var.mp_listing_resource_version]
  }
}

data "template_file" "bootstrap" {
  template = file(var.bootstrap_template)
  vars = {
    odi_vnc_password = var.odi_vnc_password
    adw_instance     = var.adw_instance
    adw_username     = var.adw_username
    adw_password     = data.terraform_remote_state.adw.outputs.adw_admin_password
    odi_password        = var.odi_password
    odi_schema_prefix   = var.odi_schema_prefix
    odi_schema_password = var.odi_schema_password
    adw_creation_mode = var.odi_repo
    embedded_db       = "false"
    studio_mode       = var.studio_mode
    db_tech             = "ADB"
    register_repository = "false"
    show_adp_desktop = "false"
    studio_name      = var.studio_name
  }
}

resource "oci_core_instance" "odi" {
  availability_domain = var.availability_domain
  compartment_id      = var.compartment_id
  display_name        = var.odi_instance_name
  shape               = var.shape
  defined_tags        = merge(var.tags, var.env_tag)
  dynamic "shape_config" {
    for_each = var.is_flexible_instance_shape ? [1] : []
    content {
      ocpus         = var.instance_ocpus
      memory_in_gbs = var.instance_memory
    }
  }

  create_vnic_details {
    subnet_id = var.subnet_id
    assign_public_ip = var.assign_public_ip
    hostname_label   = "odi-node-1"
  }

  source_details {
    source_type             = "image"
    source_id               = var.mp_listing_resource_id
    boot_volume_size_in_gbs = var.boot_volume_size_in_gbs
    boot_volume_vpus_per_gb = "20"
    kms_key_id              = oci_kms_key.test_key.id
  }

  metadata = {
    ssh_authorized_keys = file(var.ssh_public_key_path)
    user_data           = base64encode(data.template_file.bootstrap.rendered)
  }

  timeouts {
    create = "60m"
  }
  preserve_boot_volume = false
}

Debug Output

Panic Output

Expected Behavior

ODI Classic to be deployed via terraform and the ODI studio must be running

Actual Behavior

ODI studio is not running and exited with below error

[ERROR] Storing the MP Repo Mode fails, Hence exiting the process !!!

tf-oci-pub commented 6 months ago

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

dennis-mac-oracle commented 6 months ago

Found this https://support.oracle.com/knowledge/Oracle%20Cloud/2806808_1.html

When provisioning an Oracle Data Integrator (ODI) on Marketplace instance, it fails with the following error:

Starting repository creation for db tech
Finished MP configuration
Going to start Apps

  [ERROR] Storing the MP Repo Mode fails, Hence exiting the process !!!

Cause: ODI Schema password does not contain any uppercase characters. It requires at least 12 alphanumeric characters, one or more of them as uppercase characters.

Solution: Make sure odiSchemaPassword is at least 12 alphanumeric characters, one or more of them as uppercase characters.