Commit ea751046 authored by Chris King's avatar Chris King
Browse files

Feedback fixes

* Add cloud-init.yml to nodes to auto-license SUSE instances
* Rename 'bastion' instance to 'mgr' (manager)
* Add variable for DNS on public network and force DNS to a known-functional
  configuration by default
* Change instance image default from SLES 15 SP3 to SP2
parent cf73562a
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/template" {
version = "2.2.0"
hashes = [
"h1:94qn780bi1qjrbC3uQtjJh3Wkfwd5+tTtJHOb7KTg9w=",
"zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386",
"zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53",
"zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603",
"zh:0e3a6c8e16f17f19010accd0844187d524580d9fdb0731f675ffcf4afba03d16",
"zh:45f2c594b6f2f34ea663704cc72048b212fe7d16fb4cfd959365fa997228a776",
"zh:77ea3e5a0446784d77114b5e851c970a3dde1e08fa6de38210b8385d7605d451",
"zh:8a154388f3708e3df5a69122a23bdfaf760a523788a5081976b3d5616f7d30ae",
"zh:992843002f2db5a11e626b3fc23dc0c87ad3729b3b3cff08e32ffb3df97edbde",
"zh:ad906f4cebd3ec5e43d5cd6dc8f4c5c9cc3b33d2243c89c5fc18f97f7277b51d",
"zh:c979425ddb256511137ecd093e23283234da0154b7fa8b21c2687182d9aea8b2",
]
}
provider "registry.terraform.io/terraform-provider-openstack/openstack" {
version = "1.35.0"
constraints = "~> 1.35.0"
......
# data for reference image
data "openstack_images_image_v2" "base_image" {
name = var.base_image_name
}
......@@ -9,10 +10,22 @@ data "openstack_compute_flavor_v2" "m1_small" {
name = "m1.small"
}
# bastion node
resource "openstack_compute_instance_v2" "bastion" {
name = "bastion"
# template file cloud-init.yml
data "template_file" "cloud_init_yml" {
template = file("${path.module}/templates/cloud-init.yml")
vars = {
sles_reg_code = var.sles_reg_code
sles_reg_email = var.sles_reg_email
sles_ses_reg = var.sles_ses_reg
}
}
# manager node
resource "openstack_compute_instance_v2" "mgr" {
name = "mgr"
image_id = data.openstack_images_image_v2.base_image.id
flavor_id = data.openstack_compute_flavor_v2.m1_small.id
key_pair = var.ssh_keypair
......@@ -21,6 +34,8 @@ resource "openstack_compute_instance_v2" "bastion" {
openstack_compute_secgroup_v2.allow_ssh.name
]
user_data = data.template_file.cloud_init_yml.rendered
block_device {
# this is the image to clone from
uuid = data.openstack_images_image_v2.base_image.id
......@@ -44,9 +59,9 @@ resource "openstack_compute_instance_v2" "bastion" {
}
}
resource "openstack_compute_floatingip_associate_v2" "bastion_association" {
resource "openstack_compute_floatingip_associate_v2" "mgr_association" {
floating_ip = openstack_compute_floatingip_v2.floating_ip.address
instance_id = openstack_compute_instance_v2.bastion.id
instance_id = openstack_compute_instance_v2.mgr.id
}
# OSD nodes
......@@ -62,6 +77,8 @@ resource "openstack_compute_instance_v2" "osd" {
"default"
]
user_data = data.template_file.cloud_init_yml.rendered
block_device {
# this is the image to clone from
uuid = data.openstack_images_image_v2.base_image.id
......@@ -102,6 +119,8 @@ resource "openstack_compute_instance_v2" "mds" {
"default"
]
user_data = data.template_file.cloud_init_yml.rendered
block_device {
# this is the image to clone from
uuid = data.openstack_images_image_v2.base_image.id
......@@ -138,6 +157,8 @@ resource "openstack_compute_instance_v2" "mon" {
"default"
]
user_data = data.template_file.cloud_init_yml.rendered
block_device {
# this is the image to clone from
uuid = data.openstack_images_image_v2.base_image.id
......
......@@ -24,8 +24,9 @@ resource "openstack_networking_network_v2" "public_network" {
}
resource "openstack_networking_subnet_v2" "public_subnet" {
network_id = openstack_networking_network_v2.public_network.id
cidr = "10.0.0.0/24"
network_id = openstack_networking_network_v2.public_network.id
cidr = "10.0.0.0/24"
dns_nameservers = var.public_network_dns
}
# router
......
output "bastion_ip_address" {
output "manager_ip_address" {
value = openstack_compute_floatingip_v2.floating_ip.address
}
#cloud-config
runcmd:
- sudo SUSEConnect -r ${sles_reg_code} -e ${sles_reg_email}
- sudo SUSEConnect -p ses/7/x86_64 -r ${sles_ses_reg}
......@@ -4,3 +4,6 @@ appcred_id = "application_credential_id"
appcred_name = "application_credential_name"
appcred_secret = "application_credential_secret"
ssh_keypair = "ssh_keypair_name"
sles_reg_code = "suse registration code
sles_reg_email = "suse registration email"
sles_ses_reg = "suse storage extension registration code"
......@@ -31,7 +31,7 @@ variable "ssh_keypair" {
variable "base_image_name" {
type = string
default = "sles-15-sp3-x86_64"
default = "sles-15-sp2-x86_64"
description = "base image to use for the cluster"
}
......@@ -40,3 +40,24 @@ variable "osd_node_count" {
default = 3
description = "amount of OSD nodes to create"
}
variable "public_network_dns" {
type = list(string)
default = ["138.26.134.2"]
description = "dns to use for hosts - defaulted to one that works"
}
variable "sles_reg_code" {
type = string
description = "Code to register instance with SUSE connect"
}
variable "sles_reg_email" {
type = string
description = "Email to use for SUSE registration"
}
variable "sles_ses_reg" {
type = string
description = "code to register for the storage package in SUSE"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment