diff --git a/tf/oci_common_private_network/subnet.tf b/tf/oci_common_private_network/subnet.tf index 598ea8a0..2496a094 100644 --- a/tf/oci_common_private_network/subnet.tf +++ b/tf/oci_common_private_network/subnet.tf @@ -5,4 +5,12 @@ resource "oci_core_subnet" "this" { display_name = oci_core_vcn.this.display_name dns_label = "subnet" +} + +locals { + subnet = oci_core_subnet.this +} + +output "subnet_id" { + value = local.subnet.id } \ No newline at end of file diff --git a/tf/oci_servers.tf b/tf/oci_servers.tf index 8f154547..b37e33ef 100644 --- a/tf/oci_servers.tf +++ b/tf/oci_servers.tf @@ -1,3 +1,15 @@ variable "kat_pgp_ssh_public_key" { type = string +} + +module "oci_servers" { + source = "./oci_servers" + + micro_display_names = ["Mei", "Mai"] + flex_display_name = "Daiyousei" + + tenancy_ocid = module.oci_compartment_bootstrap.child_compartment_id + nsg_id = module.oci_common_private_network.nsg_id + ssh_authorized_keys = [var.kat_pgp_ssh_public_key] + subnet_id = module.oci_common_private_network.subnet_id } \ No newline at end of file diff --git a/tf/oci_servers/common.tf b/tf/oci_servers/common.tf index 23fc3ce2..8405c6fc 100644 --- a/tf/oci_servers/common.tf +++ b/tf/oci_servers/common.tf @@ -20,6 +20,10 @@ locals { ) } +variable "tenancy_ocid" { + type = string +} + data "oci_identity_availability_domains" "this" { compartment_id = var.tenancy_ocid } diff --git a/tf/oci_servers/flex.tf b/tf/oci_servers/flex.tf index 83f2098c..0906aac4 100644 --- a/tf/oci_servers/flex.tf +++ b/tf/oci_servers/flex.tf @@ -1,3 +1,9 @@ +locals { + takeover_oracle = yamlencode({ + + }) +} + data "oci_core_images" "that" { compartment_id = var.tenancy_ocid @@ -10,20 +16,28 @@ data "oci_core_images" "that" { data "cloudinit_config" "that" { part { - content = file("user-data-that.yaml") + content = local.takeover_oracle } } +variable "flex_display_name" { + type = string +} + +locals { + flex_hostname = lower(var.flex_display_name) +} + resource "oci_core_instance" "that" { availability_domain = data.oci_identity_availability_domains.this.availability_domains.0.name compartment_id = var.tenancy_ocid shape = local.shapes.flex - display_name = "Oracle Linux" + display_name = var.flex_display_name preserve_boot_volume = false metadata = { - ssh_authorized_keys = var.ssh_public_key + ssh_authorized_keys = var.ssh_authorized_keys user_data = data.cloudinit_config.that.rendered } @@ -39,10 +53,10 @@ resource "oci_core_instance" "that" { create_vnic_details { assign_public_ip = true - display_name = "Oracle Linux" - hostname_label = "oracle-linux" - nsg_ids = [oci_core_network_security_group.this.id] - subnet_id = oci_core_subnet.this.id + display_name = var.flex_display_name + hostname_label = local.flex_hostname + nsg_ids = [var.nsg_id] + subnet_id = var.subnet_id } shape_config { diff --git a/tf/oci_servers/micro.tf b/tf/oci_servers/micro.tf index 8ae2bfac..c475017f 100644 --- a/tf/oci_servers/micro.tf +++ b/tf/oci_servers/micro.tf @@ -1,5 +1,4 @@ locals { - display_name = ["Mei", "Mai"] takeover_ubuntu = yamlencode({ }) @@ -27,6 +26,22 @@ data "cloudinit_config" "this" { } } +variable "micro_display_names" { + type = list(string) +} + +variable "ssh_authorized_keys" { + type = list(string) +} + +variable "nsg_id" { + type = any +} + +variable "subnet_id" { + type = any +} + resource "oci_core_instance" "this" { count = 2 @@ -34,11 +49,11 @@ resource "oci_core_instance" "this" { compartment_id = var.tenancy_ocid shape = local.shapes.micro - display_name = local.display_name[count.index] + display_name = var.micro_display_names[count.index] preserve_boot_volume = false metadata = { - ssh_authorized_keys = var.ssh_public_key + ssh_authorized_keys = var.ssh_authorized_keys user_data = data.cloudinit_config.this.rendered } @@ -53,10 +68,10 @@ resource "oci_core_instance" "this" { } create_vnic_details { - display_name = format("Ubuntu %d", count.index + 1) - hostname_label = format("ubuntu-%d", count.index + 1) - nsg_ids = [oci_core_network_security_group.this.id] - subnet_id = oci_core_subnet.this.id + display_name = var.micro_display_names[count.index] + hostname_label = lower(var.micro_display_names[count.index]) + nsg_ids = [var.nsg_id] + subnet_id = var.subnet_id } source_details { diff --git a/tf/terraform.tf b/tf/terraform.tf index 97a6ade8..9907e27c 100644 --- a/tf/terraform.tf +++ b/tf/terraform.tf @@ -24,7 +24,7 @@ terraform { } } - #/* + /* # Settings for local applies backend "remote" { hostname = "app.terraform.io" @@ -33,9 +33,9 @@ terraform { name = "nixfiles-tf" } } - #*/ + */ - /* + #/* # Settings for remote applies cloud { organization = "kittywitch" @@ -46,5 +46,5 @@ terraform { name = "nixfiles-tf" } } - */ + #*/ } \ No newline at end of file