Skip to content

Commit 191952a

Browse files
Zhigang Wangravinitp
authored andcommitted
Added - Add support for private and 3rd party software repositories and rebooting of instances to OS Management Hub
1 parent 8155bda commit 191952a

File tree

131 files changed

+10013
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+10013
-721
lines changed

examples/os_management_hub/entitlement/main.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ variable "user_ocid" {}
66
variable "fingerprint" {}
77
variable "private_key_path" {}
88
variable "region" {}
9-
variable "compartment_id" {}
10-
variable "lifecycle_stage_id" {}
11-
9+
variable "compartment_ocid" {}
1210

1311
provider "oci" {
1412
tenancy_ocid = var.tenancy_ocid
@@ -19,8 +17,6 @@ provider "oci" {
1917
}
2018

2119
# List all entitlements in a compartment
22-
# --------------------------------------
2320
data "oci_os_management_hub_entitlements" "test_entitlements" {
24-
compartment_id = "${var.compartment_id}"
21+
compartment_id = "${var.compartment_ocid}"
2522
}
26-

examples/os_management_hub/erratum/main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variable "user_ocid" {}
66
variable "fingerprint" {}
77
variable "private_key_path" {}
88
variable "region" {}
9-
variable "compartment_id" {}
9+
variable "compartment_ocid" {}
1010

1111
provider "oci" {
1212
tenancy_ocid = var.tenancy_ocid
@@ -19,28 +19,28 @@ provider "oci" {
1919

2020
data "oci_os_management_hub_errata" "test_errata" {
2121
#Required
22-
compartment_id = "${var.compartment_id}"
22+
compartment_id = "${var.compartment_ocid}"
2323

2424
#Optional
25-
name = ["ELBA-2024-12244"]
25+
name = ["ELBA-2024-12244"]
2626
name_contains = "ELBA-2024-12244"
2727
}
2828

2929
data "oci_os_management_hub_errata" "test_errata_2" {
3030
#Required
31-
compartment_id = "${var.compartment_id}"
31+
compartment_id = "${var.compartment_ocid}"
3232

3333
#Optional
34-
classification_type = ["BUGFIX"]
35-
name = ["ELBA-2024-12244"]
36-
name_contains = "ELBA-2024-12244"
37-
os_family = "ORACLE_LINUX_9"
38-
time_issue_date_end = "2024-04-01T00:00:00.000Z"
34+
classification_type = ["BUGFIX"]
35+
name = ["ELBA-2024-12244"]
36+
name_contains = "ELBA-2024-12244"
37+
os_family = "ORACLE_LINUX_9"
38+
time_issue_date_end = "2024-04-01T00:00:00.000Z"
3939
time_issue_date_start = "2024-03-20T00:00:00.000Z"
4040
}
4141

4242

4343
data "oci_os_management_hub_erratum" "test_erratum" {
44-
compartment_id = "${var.compartment_id}"
45-
name = "ELBA-2024-12244"
44+
compartment_id = "${var.compartment_ocid}"
45+
name = "ELBA-2024-12244"
4646
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# set -x -e
4+
5+
# . ~/venv-amd64/bin/activate
6+
7+
response="$(oci raw-request --http-method POST --target-uri "https://osmh.us-ashburn-1.oci.oraclecloud.com/20220901/events" --request-body '
8+
{
9+
"eventSummary": "Manually created event 2 for testing caused by <Yijiu>",
10+
"type": "EXPLOIT_ATTEMPT",
11+
"data": {
12+
"content": {
13+
"type": "EXPLOIT_ATTEMPT",
14+
"exploitDetectionLogContent": "exploitDetectionLogContent",
15+
"contentLocation": "/var/lib/oracle-cloud-agent/plugins/oci-alx/oops/reports/2488906d741741b3349615959ddfa7b3cd047d50.2020-07-14T01:38:28.000Z"
16+
},
17+
"count": 2,
18+
"additionalDetails": {
19+
"exploitCves": [
20+
"CVE-1234",
21+
"CVE-2222"
22+
]
23+
}
24+
},
25+
"eventDetails": "Autonomous instance has an exploit",
26+
"timeOccurred": "2024-01-25T23:00:49.382Z",
27+
"timeCreated": "2023-12-05T03:31:09.844Z",
28+
"timeUpdated": "2023-12-04T22:52:50.411Z",
29+
"compartmentId": "ocid1.tenancy.oc1..aaaaaaaatajukaw53bfyxan7qlhje4u6v5hvfa3la7jbh7cok3qukw7rirbq",
30+
"resourceId": "ocid1.instance.oc1.iad.anuwcljt22fr4bicxlufr5l3xmrts2ttuvn2cmx3ozrhopindb25jgfwyg3q",
31+
"systemDetails": {
32+
"architecture": "X86_64",
33+
"kspliceEffectiveKernelVersion": "5.4.17-2102.201.3.el7uek.x86_64",
34+
"osFamily": "ORACLE_LINUX_8",
35+
"osName": "ORACLE_LINUX_SERVER",
36+
"osKernelRelease": "#2 SMP Fri Apr 23 09:05:55 PDT 2021",
37+
"osKernelVersion": "5.4.17-2102.201.3.el7uek.x86_64",
38+
"osSystemVersion": "8.2"
39+
},
40+
"isManagedByAutonomousLinux": true,
41+
"freeformTags": {
42+
"Department": "Finance"
43+
}
44+
}
45+
')"
46+
47+
id="$(echo "$response" | jq -r '.data.id')"
48+
49+
cat <<EOF
50+
{
51+
"id": "$id"
52+
}
53+
EOF
Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
22
// Licensed under the Mozilla Public License v2.0
3+
34
variable "tenancy_ocid" {}
45
variable "user_ocid" {}
56
variable "fingerprint" {}
67
variable "private_key_path" {}
78
variable "region" {}
8-
variable "compartment_id" {}
9-
variable "event_id" {}
9+
variable "compartment_ocid" {}
1010
variable "osmh_managed_instance_ocid" {}
1111

12+
# terraform {
13+
# required_providers {
14+
# oci = {
15+
# source = "oracle/oci"
16+
# version = "0.0.1"
17+
# }
18+
# }
19+
# }
20+
1221
provider "oci" {
1322
tenancy_ocid = var.tenancy_ocid
1423
user_ocid = var.user_ocid
@@ -17,40 +26,53 @@ provider "oci" {
1726
region = var.region
1827
}
1928

20-
2129
# Event has no public create API. Refer to https://confluence.oci.oraclecorp.com/x/Q5W15Q for creating events.
2230

23-
### Event
31+
locals {
32+
has_event_id = data.external.create_osmh_event.result.id != null && data.external.create_osmh_event.result.id != ""
33+
}
34+
35+
data "external" "create_osmh_event" {
36+
program = ["bash", "${path.module}/create-osmh-event.sh"]
37+
}
38+
39+
output "osmh_event_id" {
40+
value = data.external.create_osmh_event.result.id
41+
}
42+
2443
# Update tag and compartment
2544
resource "oci_os_management_hub_event" "test_event" {
26-
compartment_id = "${var.compartment_id}"
27-
event_id = "${var.event_id}"
45+
count = local.has_event_id ? 1 : 0
46+
47+
compartment_id = var.compartment_ocid
48+
event_id = data.external.create_osmh_event.result.id
2849
freeform_tags = {
2950
"Department" = "Finance"
3051
}
3152
}
3253

3354
# List Event
34-
3555
data "oci_os_management_hub_events" "test_events" {
36-
compartment_id = "${var.compartment_id}"
37-
event_summary = "Manually created event 2 for testing caused by <Yijiu>"
56+
compartment_id = var.compartment_ocid
57+
event_summary = "Manually created event 2 for testing caused by <Yijiu>"
3858
event_summary_contains = "testing"
3959
filter {
40-
name = "id"
41-
values = ["${var.event_id}"]
60+
name = "id"
61+
values = [data.external.create_osmh_event.result.id]
4262
}
43-
id = "${var.event_id}"
44-
is_managed_by_autonomous_linux = "true"
45-
resource_id = "${var.osmh_managed_instance_ocid}"
46-
state = "ACTIVE"
63+
id = data.external.create_osmh_event.result.id
64+
is_managed_by_autonomous_linux = "true"
65+
resource_id = var.osmh_managed_instance_ocid
66+
state = "ACTIVE"
4767
time_created_greater_than_or_equal_to = "2018-01-01T00:00:00.000Z"
48-
time_created_less_than = "2088-01-01T00:00:00.000Z"
49-
type = ["EXPLOIT_ATTEMPT"]
68+
time_created_less_than = "2088-01-01T00:00:00.000Z"
69+
type = ["EXPLOIT_ATTEMPT"]
5070
}
5171

5272
# Get Event
5373
data "oci_os_management_hub_event" "test_event" {
74+
count = local.has_event_id ? 1 : 0
75+
5476
# Required
55-
event_id = "${var.event_id}"
77+
event_id = data.external.create_osmh_event.result.id
5678
}

0 commit comments

Comments
 (0)