Skip to content

Commit 7f075af

Browse files
authored
feat: add support for cloud agent plugins (#91)
Fix: #17 This change adds a new input variable var.cloud_agent_plugins type map(string). It allows to individually enable or disable an Oracle Cloud Agent plugin. # ! provider seems to have a bug with plugin_config the stanza // the configuration is applied at first resource creation // subsequent updates are detected as changes by Terraform but seems to be ignored by oci provider.
1 parent 1cd206a commit 7f075af

File tree

6 files changed

+128
-10
lines changed

6 files changed

+128
-10
lines changed

CHANGELOG.adoc

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ Given a version number MAJOR.MINOR.PATCH:
1414
* MINOR version when adding functionality in a backwards compatible manner,
1515
* PATCH version when making backwards compatible bug fixes.
1616
17+
== 2.4.0 - unreleased
18+
19+
=== New features
20+
21+
* Add support for burstable instances (fix #66)
22+
* Add support for Oracle Cloud Agent pulgins configuration (fix #17)
23+
24+
=== Fixes
25+
26+
* Instance display name no longer automatically append a number when only one instance is configured
27+
1728
== 2.3.0 - 2021-11-12
1829

1930
=== New features

docs/terraformoptions.adoc

+29-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[cols="a,a",options="header,autowidth"]
1313
|===
1414
|Name |Version
15-
|[[provider_oci]] <<provider_oci,oci>> |>= 3.27
15+
|[[provider_oci]] <<provider_oci,oci>> |4.61.0
1616
|===
1717
== Resources
1818

@@ -55,6 +55,12 @@
5555
|`"paravirtualized"`
5656
|no
5757

58+
|[[input_baseline_ocpu_utilization]] <<input_baseline_ocpu_utilization,baseline_ocpu_utilization>>
59+
|(Updatable) The baseline OCPU utilization for a subcore burstable VM instance
60+
|`string`
61+
|`"BASELINE_1_1"`
62+
|no
63+
5864
|[[input_block_storage_sizes_in_gbs]] <<input_block_storage_sizes_in_gbs,block_storage_sizes_in_gbs>>
5965
|Sizes of volumes to create and attach to each instance.
6066
|`list(number)`
@@ -73,6 +79,28 @@
7379
|`null`
7480
|no
7581

82+
|[[input_cloud_agent_plugins]] <<input_cloud_agent_plugins,cloud_agent_plugins>>
83+
|Whether each Oracle Cloud Agent plugins should be ENABLED or DISABLED.
84+
|`map(string)`
85+
|
86+
87+
[source]
88+
----
89+
{
90+
"autonomous_linux": "ENABLED",
91+
"bastion": "ENABLED",
92+
"block_volume_mgmt": "DISABLED",
93+
"custom_logs": "ENABLED",
94+
"management": "DISABLED",
95+
"monitoring": "ENABLED",
96+
"osms": "ENABLED",
97+
"run_command": "ENABLED",
98+
"vulnerability_scanning": "ENABLED"
99+
}
100+
----
101+
102+
|no
103+
76104
|[[input_compartment_ocid]] <<input_compartment_ocid,compartment_ocid>>
77105
|(Updatable) The OCID of the compartment where to create all resources
78106
|`string`
@@ -121,12 +149,6 @@
121149
|`null`
122150
|no
123151

124-
|[[baseline_ocpu_utilization]] <<input_baseline_ocpu_utilization,baseline_ocpu_utilization>>
125-
|(Updatable) The baseline OCPU utilization for a subcore burstable VM instance.
126-
|`string`
127-
|`BASELINE_1_1`
128-
|no
129-
130152
|[[input_instance_flex_ocpus]] <<input_instance_flex_ocpus,instance_flex_ocpus>>
131153
|(Updatable) The total number of OCPUs available to the instance.
132154
|`number`

examples/instances_fixed_shape/main.tf

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ module "instance_nonflex" {
3232
shape = var.shape
3333
source_ocid = var.source_ocid
3434
source_type = var.source_type
35+
cloud_agent_plugins = {
36+
autonomous_linux = "ENABLED"
37+
bastion = "ENABLED"
38+
vulnerability_scanning = "ENABLED"
39+
osms = "ENABLED"
40+
management = "DISABLED"
41+
custom_logs = "ENABLED"
42+
run_command = "ENABLED"
43+
monitoring = "ENABLED"
44+
block_volume_mgmt = "DISABLED"
45+
}
3546
# operating system parameters
3647
ssh_public_keys = var.ssh_public_keys
3748
# networking parameters

examples/instances_flex_shape/main.tf

+12-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ module "instance_flex" {
3535
source_type = var.source_type
3636
instance_flex_memory_in_gbs = var.instance_flex_memory_in_gbs # only used if shape is Flex type
3737
instance_flex_ocpus = 1 # only used if shape is Flex type
38-
baseline_ocpu_utilization = var.baseline_ocpu_utilization
38+
baseline_ocpu_utilization = var.baseline_ocpu_utilization
39+
cloud_agent_plugins = {
40+
autonomous_linux = "ENABLED"
41+
bastion = "ENABLED"
42+
vulnerability_scanning = "ENABLED"
43+
osms = "ENABLED"
44+
management = "DISABLED"
45+
custom_logs = "ENABLED"
46+
run_command = "ENABLED"
47+
monitoring = "ENABLED"
48+
block_volume_mgmt = "DISABLED"
49+
}
3950
# operating system parameters
4051
ssh_public_keys = var.ssh_public_keys
4152
# networking parameters

main.tf

+48-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,57 @@ resource "oci_core_instance" "instance" {
7878
shape_config {
7979
// If shape name contains ".Flex" and instance_flex inputs are not null, use instance_flex inputs values for shape_config block
8080
// Else use values from data.oci_core_shapes.current_ad for var.shape
81-
memory_in_gbs = local.shape_is_flex == true && var.instance_flex_memory_in_gbs != null ? var.instance_flex_memory_in_gbs : local.shapes_config[var.shape]["memory_in_gbs"]
82-
ocpus = local.shape_is_flex == true && var.instance_flex_ocpus != null ? var.instance_flex_ocpus : local.shapes_config[var.shape]["ocpus"]
81+
memory_in_gbs = local.shape_is_flex == true && var.instance_flex_memory_in_gbs != null ? var.instance_flex_memory_in_gbs : local.shapes_config[var.shape]["memory_in_gbs"]
82+
ocpus = local.shape_is_flex == true && var.instance_flex_ocpus != null ? var.instance_flex_ocpus : local.shapes_config[var.shape]["ocpus"]
8383
baseline_ocpu_utilization = var.baseline_ocpu_utilization
8484
}
8585

86+
agent_config {
87+
are_all_plugins_disabled = false
88+
is_management_disabled = false
89+
is_monitoring_disabled = false
90+
91+
# ! provider seems to have a bug with plugin_config stanzas below
92+
// this configuration is applied at first resource creation
93+
// subsequent updates are detected as changes by terraform but seems to be ignored by the provider ...
94+
plugins_config {
95+
desired_state = var.cloud_agent_plugins.autonomous_linux
96+
name = "Oracle Autonomous Linux"
97+
}
98+
plugins_config {
99+
desired_state = var.cloud_agent_plugins.bastion
100+
name = "Bastion"
101+
}
102+
plugins_config {
103+
desired_state = var.cloud_agent_plugins.block_volume_mgmt
104+
name = "Block Volume Management"
105+
}
106+
plugins_config {
107+
desired_state = var.cloud_agent_plugins.custom_logs
108+
name = "Custom Logs Monitoring"
109+
}
110+
plugins_config {
111+
desired_state = var.cloud_agent_plugins.management
112+
name = "Management Agent"
113+
}
114+
plugins_config {
115+
desired_state = var.cloud_agent_plugins.monitoring
116+
name = "Compute Instance Monitoring"
117+
}
118+
plugins_config {
119+
desired_state = var.cloud_agent_plugins.osms
120+
name = "OS Management Service Agent"
121+
}
122+
plugins_config {
123+
desired_state = var.cloud_agent_plugins.run_command
124+
name = "Compute Instance Run Command"
125+
}
126+
plugins_config {
127+
desired_state = var.cloud_agent_plugins.vulnerability_scanning
128+
name = "Vulnerability Scanning"
129+
}
130+
}
131+
86132
create_vnic_details {
87133
assign_public_ip = var.public_ip == "NONE" ? var.assign_public_ip : false
88134
display_name = var.vnic_name == "" ? "" : var.instance_count != "1" ? "${var.vnic_name}_${count.index + 1}" : var.vnic_name

variables.tf

+17
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ variable "shape" {
9191
default = "VM.Standard2.1"
9292
}
9393

94+
variable "cloud_agent_plugins" {
95+
description = "Whether each Oracle Cloud Agent plugins should be ENABLED or DISABLED."
96+
type = map(string)
97+
default = {
98+
autonomous_linux = "ENABLED"
99+
bastion = "ENABLED"
100+
block_volume_mgmt = "DISABLED"
101+
custom_logs = "ENABLED"
102+
management = "DISABLED"
103+
monitoring = "ENABLED"
104+
osms = "ENABLED"
105+
run_command = "ENABLED"
106+
vulnerability_scanning = "ENABLED"
107+
}
108+
#* need to craft a validation condition at some point
109+
}
110+
94111
variable "baseline_ocpu_utilization" {
95112
description = "(Updatable) The baseline OCPU utilization for a subcore burstable VM instance"
96113
type = string

0 commit comments

Comments
 (0)