Check in to allow collaboration.

new-vpc
Curtis Wilson 4 years ago
parent 8283730606
commit d610a72022

@ -11,20 +11,33 @@ locals {
]
aws-security-group-id = module.aws-network-existing.default-sg.id
# aws-security-group-id = module.aws-network-from-scratch.default-security-group.id
# The names of these nodes is created by:
# "{var.vm-name-prefix}-{name from nodes-config}-{number}"
# The length of this full name must be < 16 characters. This is a limitaion of
# Active Directory? The "realm join" command failed when the name was too
# long, although it did not give the reason for the failure, the reason was
# surmised because it looked like it was truncating the name when attempting
# to join.
nodes-config = {
# TODO if the above comment about the name length is true, then this name is
# too long. IMPORTANT! If you change this then you need to change the k8s
# ansible role that assigns roles based on wether or not 'master' is in the
# name.
"k8s-master" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-medium-4gib-2vcpu
subnet-ids = local.k8s-subnets-ids
num = 0
num = 1
},
"k8s-worker" = {
"k8s-wrkr" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-medium-4gib-2vcpu
subnet-ids = local.k8s-subnets-ids
num = 0
disk-size = 20
num = 2
},
"ansible-test" = {
"test" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-micro-1gib-1vcpu
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
@ -38,7 +51,7 @@ locals {
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
num = 1
num-disks = 1
disk-size = 10
zfs-disk-size = 10
},
"proxy" = {
base-image = var.ubuntu-ami
@ -119,7 +132,7 @@ resource "aws_key_pair" "key" {
resource "aws_ebs_volume" "zfs" {
# TODO REM look at types.
availability_zone = local.nfs-subnets[0].availability_zone
size = local.nodes-config["nfs"].disk-size
size = local.nodes-config["nfs"].zfs-disk-size
encrypted = true
count = local.nodes-config["nfs"].num-disks
tags = {
@ -147,12 +160,27 @@ module "nodes" {
private-ips = try(each.value.private-ips, [])
security-group-ids = [local.aws-security-group-id]
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
disk-size = try(each.value.disk-size, null)
num-nodes = each.value.num
name-prefix = "${var.vm-name-prefix}-${each.key}"
# TODO add a input for the key so that it will show up as the key in the aws
# console.
}
# TODO an attempt to create a windows machine.
# module "nodes-win" {
# source = "./modules/aws-nodes"
# ec2-instance-type = var.t2-small-2gib-1vcpu
# ami = var.win-srv-2019-ami
# subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_2"].id]
# private-ips = []
# security-group-ids = [local.aws-security-group-id]
# # TODO REM need to figure out how to not pass a user data.
# user-datas = [null]
# num-nodes = 1
# name-prefix = "${var.vm-name-prefix}-win-test"
# }
################################################################################
# end aws
################################################################################

@ -48,7 +48,14 @@ locals {
# us-gov-west-1
owner-id = "219670896067"
name = "RHEL-8.*HVM*x86_64*GP2"
}
},
win-srv-2019 = {
# us-east-2
# owner-id = "???"
# us-gov-west-1
owner-id = "077303321853"
name = "Windows_Server-2019-English-Full-Base*"
},
}
}

@ -9,6 +9,10 @@ resource "aws_instance" "nodes" {
private_ip = length(var.private-ips) == 0 ? null : element(var.private-ips, count.index)
vpc_security_group_ids = var.security-group-ids
user_data = element(var.user-datas.*.rendered, count.index)
root_block_device {
volume_size = var.disk-size
delete_on_termination = true
}
count = var.num-nodes
tags = {

@ -3,6 +3,12 @@ variable "ami" {
type = string
}
variable "disk-size" {
default = 8
description = "The size of the root FS disk in GB."
type = number
}
variable "ec2-instance-type" {
default = "t2.micro"
description = "The AWS instance type to use for all nodes."

@ -122,14 +122,14 @@ variable "amzn2-ami" {
# us-east-2
# default = "ami-0dd0ccab7e2801812"
# us-gov-west-1
default = "ami-098bf51d9a35299f0"
default = "ami-02ab588324a95cf31"
description = "The AMI to use for Amazon Linux 2."
}
variable "ubuntu-ami" {
# us-east-2
# default = "ami-06c7d6c0987eaa46c"
# us-gov-west-1
default = "ami-087ee83c8de303181"
default = "ami-066189aeb91baa0ab"
description = "The AMI to use for Ubuntu."
}
variable "centos7-ami" {
@ -161,6 +161,13 @@ variable "rhel8-ami" {
default = "ami-0b1f10cd1cd107dd2"
description = "The AMI to use for RHEL 8."
}
variable "win-srv-2019-ami" {
# us-east-2
# default = ???
# us-gov-west-1
default = "ami-0f838c3c35ab60fc4"
description = "The AMI to use for Windows Server 2019."
}
################################################################################
# AWS EC2 types.
@ -173,6 +180,11 @@ variable "t2-micro-1gib-1vcpu" {
default = "t2.micro"
}
variable "t2-small-2gib-1vcpu" {
description = "t2.small EC2 instance with 2 GiB mem and 1 vCPUs."
default = "t2.small"
}
variable "t2-medium-4gib-2vcpu" {
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
default = "t2.medium"

Loading…
Cancel
Save