Skip to content

Commit 610ba9f

Browse files
authored
Support for flex shape and silent cloud init script (#25)
* set minimum version to Terraform 0.13 * added support for flex shape and silent mode for cloud init script
1 parent 1f8f1ec commit 610ba9f

File tree

6 files changed

+50
-13
lines changed

6 files changed

+50
-13
lines changed

compute.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ resource "oci_core_instance" "operator" {
2121

2222
display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
2323

24+
launch_options {
25+
boot_volume_type = "PARAVIRTUALIZED"
26+
network_type = "PARAVIRTUALIZED"
27+
}
28+
2429
# prevent the operator from destroying and recreating itself if the image ocid changes
2530
lifecycle {
2631
ignore_changes = [source_details[0].source_id]
@@ -31,7 +36,16 @@ resource "oci_core_instance" "operator" {
3136
user_data = data.template_cloudinit_config.operator[0].rendered
3237
}
3338

34-
shape = var.operator_shape
39+
shape = lookup(var.operator_shape, "shape", "VM.Standard.E2.2")
40+
41+
dynamic "shape_config" {
42+
for_each = length(regexall("Flex", lookup(var.operator_shape, "shape", "VM.Standard.E3.Flex"))) > 0 ? [1] : []
43+
content {
44+
ocpus = max(1, lookup(var.operator_shape, "ocpus", 1))
45+
memory_in_gbs = (lookup(var.operator_shape, "memory", 4) / lookup(var.operator_shape, "ocpus", 1)) > 64 ? (lookup(var.operator_shape, "ocpus", 1) * 4) : lookup(var.operator_shape, "memory", 4)
46+
}
47+
}
48+
3549

3650
source_details {
3751
source_type = "image"

datasources.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ data "oci_core_images" "oracle_images" {
4848
compartment_id = var.compartment_id
4949
operating_system = "Oracle Linux"
5050
operating_system_version = "7.8"
51-
shape = var.operator_shape
51+
shape = lookup(var.operator_shape, "shape", "VM.Standard.E2.2")
5252
sort_by = "TIMECREATED"
5353
}
5454

docs/terraformoptions.adoc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,19 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
139139
|Oracle
140140

141141
|`operator_shape`
142-
|The shape of operator instance.
143-
|e.g. VM.Standard.E2.2
144-
|VM.Standard.E2.2
142+
|The shape of operator instance. This is now specified as a map and supports E3.Flex. If a non-Flex shape is specified, then the other parameters are ignored.
143+
|e.g. `operator_shape = {
144+
shape="VM.Standard.E3.Flex",
145+
ocpus=1,
146+
memory=4,
147+
boot_volume_size=50
148+
}`
149+
|`operator_shape = {
150+
shape="VM.Standard.E3.Flex",
151+
ocpus=1,
152+
memory=4,
153+
boot_volume_size=50
154+
}`
145155

146156
|`operator_upgrade`
147157
|Whether to upgrade the operator host packages after provisioning. It's useful to set this to false during development/testing so the operator is provisioned faster.
@@ -214,6 +224,6 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
214224
tags = {
215225
department = "finance"
216226
environment = "dev"
217-
role = "bastion"
227+
role = "operator"
218228
}
219229
----

scripts/operator.template.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
55

6-
yum update --security
6+
# yum update --security
77

8-
sed -i -e "s/autoinstall\s=\sno/# autoinstall = yes/g" /etc/uptrack/uptrack.conf
8+
# sed -i -e "s/autoinstall\s=\sno/# autoinstall = yes/g" /etc/uptrack/uptrack.conf
9+
10+
# uptrack-upgrade
911

10-
uptrack-upgrade
12+
# pip3 install oci-cli
1113

14+
yum -y -t update --security
15+
sed -i -e "s/autoinstall\s=\sno/# autoinstall = yes/g" /etc/uptrack/uptrack.conf
16+
uptrack-upgrade -y
1217
pip3 install oci-cli

terraform.tfvars.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ operator_image_id = "Oracle"
3939

4040
operator_instance_principal = true
4141

42-
operator_shape = "VM.Standard.E2.2"
42+
operator_shape = {
43+
# shape = "VM.Standard.E2.2"
44+
shape="VM.Standard.E3.Flex",
45+
ocpus=1,
46+
memory=4,
47+
boot_volume_size=50
48+
}
4349

4450
operator_upgrade = false
4551

variables.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ variable "operator_instance_principal" {
102102
}
103103

104104
variable "operator_shape" {
105-
description = "The shape of operator instance."
106-
default = "VM.Standard.E2.2"
107-
type = string
105+
description = "The shape of the operator instance."
106+
default = {
107+
shape = "VM.Standard.E3.Flex", ocpus = 1, memory = 4, boot_volume_size = 50
108+
}
109+
type = map(any)
108110
}
109111

110112
variable "operator_upgrade" {

0 commit comments

Comments
 (0)