mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-10 04:49:19 -08:00
feat(oci): attempt to make servers provisioned
This commit is contained in:
parent
0505f506d2
commit
e5b2f39e99
6 changed files with 71 additions and 18 deletions
|
|
@ -6,3 +6,11 @@ resource "oci_core_subnet" "this" {
|
||||||
display_name = oci_core_vcn.this.display_name
|
display_name = oci_core_vcn.this.display_name
|
||||||
dns_label = "subnet"
|
dns_label = "subnet"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
subnet = oci_core_subnet.this
|
||||||
|
}
|
||||||
|
|
||||||
|
output "subnet_id" {
|
||||||
|
value = local.subnet.id
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
variable "kat_pgp_ssh_public_key" {
|
variable "kat_pgp_ssh_public_key" {
|
||||||
type = string
|
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
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,10 @@ locals {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "tenancy_ocid" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
data "oci_identity_availability_domains" "this" {
|
data "oci_identity_availability_domains" "this" {
|
||||||
compartment_id = var.tenancy_ocid
|
compartment_id = var.tenancy_ocid
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
locals {
|
||||||
|
takeover_oracle = yamlencode({
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
data "oci_core_images" "that" {
|
data "oci_core_images" "that" {
|
||||||
compartment_id = var.tenancy_ocid
|
compartment_id = var.tenancy_ocid
|
||||||
|
|
||||||
|
|
@ -10,20 +16,28 @@ data "oci_core_images" "that" {
|
||||||
|
|
||||||
data "cloudinit_config" "that" {
|
data "cloudinit_config" "that" {
|
||||||
part {
|
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" {
|
resource "oci_core_instance" "that" {
|
||||||
availability_domain = data.oci_identity_availability_domains.this.availability_domains.0.name
|
availability_domain = data.oci_identity_availability_domains.this.availability_domains.0.name
|
||||||
compartment_id = var.tenancy_ocid
|
compartment_id = var.tenancy_ocid
|
||||||
shape = local.shapes.flex
|
shape = local.shapes.flex
|
||||||
|
|
||||||
display_name = "Oracle Linux"
|
display_name = var.flex_display_name
|
||||||
preserve_boot_volume = false
|
preserve_boot_volume = false
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
ssh_authorized_keys = var.ssh_public_key
|
ssh_authorized_keys = var.ssh_authorized_keys
|
||||||
user_data = data.cloudinit_config.that.rendered
|
user_data = data.cloudinit_config.that.rendered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,10 +53,10 @@ resource "oci_core_instance" "that" {
|
||||||
|
|
||||||
create_vnic_details {
|
create_vnic_details {
|
||||||
assign_public_ip = true
|
assign_public_ip = true
|
||||||
display_name = "Oracle Linux"
|
display_name = var.flex_display_name
|
||||||
hostname_label = "oracle-linux"
|
hostname_label = local.flex_hostname
|
||||||
nsg_ids = [oci_core_network_security_group.this.id]
|
nsg_ids = [var.nsg_id]
|
||||||
subnet_id = oci_core_subnet.this.id
|
subnet_id = var.subnet_id
|
||||||
}
|
}
|
||||||
|
|
||||||
shape_config {
|
shape_config {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
locals {
|
locals {
|
||||||
display_name = ["Mei", "Mai"]
|
|
||||||
takeover_ubuntu = yamlencode({
|
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" {
|
resource "oci_core_instance" "this" {
|
||||||
count = 2
|
count = 2
|
||||||
|
|
||||||
|
|
@ -34,11 +49,11 @@ resource "oci_core_instance" "this" {
|
||||||
compartment_id = var.tenancy_ocid
|
compartment_id = var.tenancy_ocid
|
||||||
shape = local.shapes.micro
|
shape = local.shapes.micro
|
||||||
|
|
||||||
display_name = local.display_name[count.index]
|
display_name = var.micro_display_names[count.index]
|
||||||
preserve_boot_volume = false
|
preserve_boot_volume = false
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
ssh_authorized_keys = var.ssh_public_key
|
ssh_authorized_keys = var.ssh_authorized_keys
|
||||||
user_data = data.cloudinit_config.this.rendered
|
user_data = data.cloudinit_config.this.rendered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,10 +68,10 @@ resource "oci_core_instance" "this" {
|
||||||
}
|
}
|
||||||
|
|
||||||
create_vnic_details {
|
create_vnic_details {
|
||||||
display_name = format("Ubuntu %d", count.index + 1)
|
display_name = var.micro_display_names[count.index]
|
||||||
hostname_label = format("ubuntu-%d", count.index + 1)
|
hostname_label = lower(var.micro_display_names[count.index])
|
||||||
nsg_ids = [oci_core_network_security_group.this.id]
|
nsg_ids = [var.nsg_id]
|
||||||
subnet_id = oci_core_subnet.this.id
|
subnet_id = var.subnet_id
|
||||||
}
|
}
|
||||||
|
|
||||||
source_details {
|
source_details {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ terraform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#/*
|
/*
|
||||||
# Settings for local applies
|
# Settings for local applies
|
||||||
backend "remote" {
|
backend "remote" {
|
||||||
hostname = "app.terraform.io"
|
hostname = "app.terraform.io"
|
||||||
|
|
@ -33,9 +33,9 @@ terraform {
|
||||||
name = "nixfiles-tf"
|
name = "nixfiles-tf"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#*/
|
*/
|
||||||
|
|
||||||
/*
|
#/*
|
||||||
# Settings for remote applies
|
# Settings for remote applies
|
||||||
cloud {
|
cloud {
|
||||||
organization = "kittywitch"
|
organization = "kittywitch"
|
||||||
|
|
@ -46,5 +46,5 @@ terraform {
|
||||||
name = "nixfiles-tf"
|
name = "nixfiles-tf"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
#*/
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue