Open gillfimj opened 4 months ago
Do you have any response on this, please? @ravinitp @varmax2511 @jotruon @vsin12 @tf-oci-pub We need this improvement. When migrating from OSMS to OSMH, we still have issues registering OCI instances. If there is an alternate way or documentation of setting up oci instances with OSMH , it would be helpful.
To register a instance with a osmh profile you need to use the resource oci_os_management_hub_managed_instance_attach_profile_management. In the instance creation you need to disable the "OS Management Service Agent" and enable "OS Management Hub Agent". The oci_os_management_hub_managed_instance_attach_profile_management attach the profile to the instance, but before you do it you need wait the osmh agent start and try to register (it will create the managed instance), if you do not wait the creating of oci_os_management_hub_managed_instance_attach_profile_management will fail because the managed instance is not created.
Example:
resource "oci_core_instance" "instance" {
agent_config {
are_all_plugins_disabled = false
is_management_disabled = false
is_monitoring_disabled = false
plugins_config {
desired_state = "DISABLED"
name = "OS Management Service Agent"
}
plugins_config {
desired_state = "ENABLED"
name = "OS Management Hub Agent"
}
}
...
...
}
resource "time_sleep" "wait_agent_registration" {
depends_on = [oci_core_instance.instance]
create_duration = "300s"
}
resource "oci_os_management_hub_managed_instance_attach_profile_management" "test_managed_instance_attach_profile_management" {
depends_on = [time_sleep.wait_agent_registration]
managed_instance_id = oci_core_instance.instance.id
profile_id = var.profile_id
}
Maybe implement a retry or timeout to oci_os_management_hub_managed_instance_attach_profile_management would be a enhancement so we dont need to use the time_sleep to wait the osmh agent.
Community Note
Description
The OS Management Hub Agent requires a profile and compartment to be specified when enabling via the OCI Console. There is no provision for this option in the oci_core_instance when "OS Management Hub Agent" is added via the plugin_config directive. Currently, the only options are
This configuration was sufficient until the release of the OS Management Hub Agent. It would be helpful to be able to specify the required compartment and profile when creating a compute instance and enabling the OS Management Hub Agent.
New or Affected Resource(s)
oci_core_instance
Potential Terraform Configuration
References
I was not able to find any other open or closed issues related to this limitation. If there is an alternate way to approach this, it would be helpful to know.