Check in to allow collaboration.
This commit is contained in:
@@ -11,20 +11,33 @@ locals {
|
|||||||
]
|
]
|
||||||
aws-security-group-id = module.aws-network-existing.default-sg.id
|
aws-security-group-id = module.aws-network-existing.default-sg.id
|
||||||
# aws-security-group-id = module.aws-network-from-scratch.default-security-group.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 = {
|
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" = {
|
"k8s-master" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
||||||
subnet-ids = local.k8s-subnets-ids
|
subnet-ids = local.k8s-subnets-ids
|
||||||
num = 0
|
num = 1
|
||||||
},
|
},
|
||||||
"k8s-worker" = {
|
"k8s-wrkr" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
||||||
subnet-ids = local.k8s-subnets-ids
|
subnet-ids = local.k8s-subnets-ids
|
||||||
num = 0
|
disk-size = 20
|
||||||
|
num = 2
|
||||||
},
|
},
|
||||||
"ansible-test" = {
|
"test" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
||||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
# 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]
|
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
|
||||||
num = 1
|
num = 1
|
||||||
num-disks = 1
|
num-disks = 1
|
||||||
disk-size = 10
|
zfs-disk-size = 10
|
||||||
},
|
},
|
||||||
"proxy" = {
|
"proxy" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
@@ -119,7 +132,7 @@ resource "aws_key_pair" "key" {
|
|||||||
resource "aws_ebs_volume" "zfs" {
|
resource "aws_ebs_volume" "zfs" {
|
||||||
# TODO REM look at types.
|
# TODO REM look at types.
|
||||||
availability_zone = local.nfs-subnets[0].availability_zone
|
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
|
encrypted = true
|
||||||
count = local.nodes-config["nfs"].num-disks
|
count = local.nodes-config["nfs"].num-disks
|
||||||
tags = {
|
tags = {
|
||||||
@@ -147,12 +160,27 @@ module "nodes" {
|
|||||||
private-ips = try(each.value.private-ips, [])
|
private-ips = try(each.value.private-ips, [])
|
||||||
security-group-ids = [local.aws-security-group-id]
|
security-group-ids = [local.aws-security-group-id]
|
||||||
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
|
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
|
num-nodes = each.value.num
|
||||||
name-prefix = "${var.vm-name-prefix}-${each.key}"
|
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
|
# TODO add a input for the key so that it will show up as the key in the aws
|
||||||
# console.
|
# 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
|
# end aws
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -48,7 +48,14 @@ locals {
|
|||||||
# us-gov-west-1
|
# us-gov-west-1
|
||||||
owner-id = "219670896067"
|
owner-id = "219670896067"
|
||||||
name = "RHEL-8.*HVM*x86_64*GP2"
|
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*"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ resource "aws_instance" "nodes" {
|
|||||||
# the IP.
|
# the IP.
|
||||||
private_ip = length(var.private-ips) == 0 ? null : element(var.private-ips, count.index)
|
private_ip = length(var.private-ips) == 0 ? null : element(var.private-ips, count.index)
|
||||||
vpc_security_group_ids = var.security-group-ids
|
vpc_security_group_ids = var.security-group-ids
|
||||||
user_data = element(var.user-datas.*.rendered, count.index)
|
user_data = element(var.user-datas.*.rendered, count.index)
|
||||||
count = var.num-nodes
|
root_block_device {
|
||||||
|
volume_size = var.disk-size
|
||||||
|
delete_on_termination = true
|
||||||
|
}
|
||||||
|
count = var.num-nodes
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "${var.name-prefix}-${count.index}"
|
Name = "${var.name-prefix}-${count.index}"
|
||||||
|
|||||||
@@ -1,30 +1,36 @@
|
|||||||
variable "ami" {
|
variable "ami" {
|
||||||
description = "The AWS AMI to be used for all the nodes"
|
description = "The AWS AMI to be used for all the nodes"
|
||||||
type = string
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "disk-size" {
|
||||||
|
default = 8
|
||||||
|
description = "The size of the root FS disk in GB."
|
||||||
|
type = number
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ec2-instance-type" {
|
variable "ec2-instance-type" {
|
||||||
default = "t2.micro"
|
default = "t2.micro"
|
||||||
description = "The AWS instance type to use for all nodes."
|
description = "The AWS instance type to use for all nodes."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "name-prefix" {
|
variable "name-prefix" {
|
||||||
default = "tf-node"
|
default = "tf-node"
|
||||||
description = "This prefix will be applied to all names created by this module."
|
description = "This prefix will be applied to all names created by this module."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "num-nodes" {
|
variable "num-nodes" {
|
||||||
default = 1
|
default = 1
|
||||||
description = "The number of nodes to create from the given input parameters."
|
description = "The number of nodes to create from the given input parameters."
|
||||||
type = number
|
type = number
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "private-ips" {
|
variable "private-ips" {
|
||||||
default = []
|
default = []
|
||||||
description = "A list of private IP addresses to use for the nodes. If the list is empty then each node will get an IP assigned from AWS."
|
description = "A list of private IP addresses to use for the nodes. If the list is empty then each node will get an IP assigned from AWS."
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "user-datas" {
|
variable "user-datas" {
|
||||||
@@ -33,10 +39,10 @@ variable "user-datas" {
|
|||||||
|
|
||||||
variable "subnet-ids" {
|
variable "subnet-ids" {
|
||||||
description = "An array of subnet ids. These subnets will be round robined as the subnet to use for each node."
|
description = "An array of subnet ids. These subnets will be round robined as the subnet to use for each node."
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "security-group-ids" {
|
variable "security-group-ids" {
|
||||||
description = "A list of security group IDs to be applied to all the nodes."
|
description = "A list of security group IDs to be applied to all the nodes."
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-2
@@ -122,14 +122,14 @@ variable "amzn2-ami" {
|
|||||||
# us-east-2
|
# us-east-2
|
||||||
# default = "ami-0dd0ccab7e2801812"
|
# default = "ami-0dd0ccab7e2801812"
|
||||||
# us-gov-west-1
|
# us-gov-west-1
|
||||||
default = "ami-098bf51d9a35299f0"
|
default = "ami-02ab588324a95cf31"
|
||||||
description = "The AMI to use for Amazon Linux 2."
|
description = "The AMI to use for Amazon Linux 2."
|
||||||
}
|
}
|
||||||
variable "ubuntu-ami" {
|
variable "ubuntu-ami" {
|
||||||
# us-east-2
|
# us-east-2
|
||||||
# default = "ami-06c7d6c0987eaa46c"
|
# default = "ami-06c7d6c0987eaa46c"
|
||||||
# us-gov-west-1
|
# us-gov-west-1
|
||||||
default = "ami-087ee83c8de303181"
|
default = "ami-066189aeb91baa0ab"
|
||||||
description = "The AMI to use for Ubuntu."
|
description = "The AMI to use for Ubuntu."
|
||||||
}
|
}
|
||||||
variable "centos7-ami" {
|
variable "centos7-ami" {
|
||||||
@@ -161,6 +161,13 @@ variable "rhel8-ami" {
|
|||||||
default = "ami-0b1f10cd1cd107dd2"
|
default = "ami-0b1f10cd1cd107dd2"
|
||||||
description = "The AMI to use for RHEL 8."
|
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.
|
# AWS EC2 types.
|
||||||
@@ -173,6 +180,11 @@ variable "t2-micro-1gib-1vcpu" {
|
|||||||
default = "t2.micro"
|
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" {
|
variable "t2-medium-4gib-2vcpu" {
|
||||||
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
|
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
|
||||||
default = "t2.medium"
|
default = "t2.medium"
|
||||||
|
|||||||
Reference in New Issue
Block a user