From 8724cede199140571a74cf9c8ea6aa8c98ed480a Mon Sep 17 00:00:00 2001 From: shnee Date: Tue, 16 Nov 2021 14:38:06 -0500 Subject: [PATCH 1/6] Create ansible invetory with get-vm-ips.sh --- .gitignore | 1 + example.tfvars | 27 ++++++++++++++++++++++ get-vm-ips.sh | 63 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index b47f542..7103111 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,5 @@ terraform.rc k8s-key* STARTHERE +inventory diff --git a/example.tfvars b/example.tfvars index 33a78d3..4b6100d 100644 --- a/example.tfvars +++ b/example.tfvars @@ -1,3 +1,5 @@ +vm-name-prefix = "docker-ansible-test" + # A CIDR block ending in '/32' equates to a single IP address, '0.0.0.0/0' # equates to any ip address. admin-ips = [ "8.8.8.8/32", "0.0.0.0/0" ] @@ -18,10 +20,35 @@ aws-ec2-instance-type = "t2.micro" # 4 GiB, 2 vcpus # aws-ec2-instnce-type = "t2.medium" +################################################################################ +# AWS images (AMIs) +################################################################################ + +## Amazon Linux 2 # AWS Amazon Linux 2 AMI (HVM), SSD Volume Type - Oregon - 2021.11.11 - free # base-image = "ami-00be885d550dcee43" # AWS Amazon Linux 2 AMI (HVM), SSD Volume Type - us-east-2 - 2021.11.12 - free base-image = "ami-0dd0ccab7e2801812" + +## CentOS +# CentOS 7.9.2009 x86_64 - us-east-2 - 2021-11-15 +# base-image = "ami-00f8e2c955f7ffa9b" +# CentOS 8.4.2105 x86_64 - us-east-2 - 2021-11015 +# base-image = "ami-057cacbfbbb471bb3" + +## Ubuntu +# Ubuntu Server 20.04 LTS (HVM), SSD Volume Type +# us-east-2 - (64-bit x86) - 2021.11.12 - free +# base-image = "ami-0629230e074c580f2" + +## Arch linux +# arch-linux-lts-hvm-2021.06.02.x86_64-ebs - us-east-2 +# base-image = "ami-02653f06de985e3ba" + +################################################################################ +# libvirt images +################################################################################ + # base-image = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img" # From https://cloud.centos.org/centos/7/images/ from 2020-11-12 06:52 # base-image = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2" diff --git a/get-vm-ips.sh b/get-vm-ips.sh index 25e36fe..8eceb68 100755 --- a/get-vm-ips.sh +++ b/get-vm-ips.sh @@ -1,19 +1,60 @@ #!/bin/sh +# This script will create environment variables for all of the output IPs. It +# will also create a `ANSIBLE_INV` variable that will be a comma separated +# string of all the IPs. A anisble inventory file called "inventory is created +# as well. +# # Use eval $(./get-vm-ips.sh) to set env vars for ips. terraform refresh > /dev/null -IPS_JSON="$(terraform show -json | jq '.values.outputs')" +# All terraform outputs in json format. +OUTPUTS_JSON="$( + terraform show -json | \ + jq '.values.outputs' | \ + sed 's/-/_/g')" +# Just the IP address outputs in json format. Also all '-' characters are +# replaced by '_' becuase '-' causes jq some problems. +IPS_JSON="$( + echo $OUTPUTS_JSON | \ + jq 'to_entries | .[] | select(.key | contains("ips"))')" +# An array of all node "types" +NODE_TYPE_ARRAY="$( + echo $IPS_JSON | \ + jq '.key' | \ + sed 's/"//g' | \ + sed -z 's/\n/ /g;s/ $/\n/g')" -echo $IPS_JSON | \ - jq '."master-ips".value[]' | \ - nl -v 0 | \ - awk '{print "export MASTER" $1 "=" $2}' | \ - sed 's/"//g' +# Loop over all the node types and create an export line for each IP. +VM_IP_EXPORTS="$( + for TYPE in $NODE_TYPE_ARRAY; do -echo $IPS_JSON | \ - jq '."worker-ips".value[]' | \ - nl -v 0 | \ - awk '{print "export WORKER" $1 "=" $2}' | \ - sed 's/"//g' + # Convert type, converts "master-ips" to "MASTER" + TYPE_UPPER="$(echo ${TYPE^^} | sed s/_.*$//g)" + echo "$OUTPUTS_JSON" | \ + jq '.'"$TYPE"'.value[]' | \ + # Add line numbers starting with 0. + nl -v 0 | \ + # Print an export string with a type placeholder "__TYPE__". + awk '{print "export __TYPE__" $1 "=" $2}' | \ + sed s/__TYPE__/$TYPE_UPPER/g + done)" + +ANSIBLE_INV="$( + echo "$VM_IP_EXPORTS" | \ + sed 's/"//g' | \ + sed 's/^.*=//g' | \ + sed -z 's/\n/,/g;s/,$/\n/g')" + +# Create an inventory file for ansible. +echo "[k8s_nodes]" > inventory +echo $VM_IP_EXPORTS | \ + sed 's/"//g' | \ + sed 's/export //g' | \ + sed 's/ /\n/g' | \ + sed 's/^\(.*\)\(=.*\)$/\1 ansible_host\2/g' \ + >> inventory + +echo $VM_IP_EXPORTS | sed 's/" /"\n/g' +echo export ANSIBLE_INV=$ANSIBLE_INV From 3088e2295f7a4aeedb4d5713e6edef25f60926c1 Mon Sep 17 00:00:00 2001 From: shnee Date: Wed, 17 Nov 2021 14:18:31 -0500 Subject: [PATCH 2/6] Added a aws_ami module. --- main.tf | 8 +++++ modules/aws-amis/main.tf | 58 +++++++++++++++++++++++++++++++++++++ modules/aws-amis/outputs.tf | 3 ++ 3 files changed, 69 insertions(+) create mode 100644 modules/aws-amis/main.tf create mode 100644 modules/aws-amis/outputs.tf diff --git a/main.tf b/main.tf index 20f8bfc..69c7943 100644 --- a/main.tf +++ b/main.tf @@ -42,6 +42,10 @@ provider "aws" { region = "us-east-2" } +module "aws-amis" { + source = "./modules/aws-amis" +} + module "aws-network" { source = "./modules/aws-network" name-prefix = var.vm-name-prefix @@ -82,6 +86,10 @@ module "worker-nodes" { name-prefix = "${var.vm-name-prefix}-worker" } +output "amis" { + value = module.aws-amis.amis +} + ################################################################################ # end aws ################################################################################ diff --git a/modules/aws-amis/main.tf b/modules/aws-amis/main.tf new file mode 100644 index 0000000..1949653 --- /dev/null +++ b/modules/aws-amis/main.tf @@ -0,0 +1,58 @@ +locals { + amis = { + amzn2 = { + owner-id = "137112412989" + name = "amzn2-ami-hvm-2*x86_64-gp2" + }, + ubuntu = { + owner-id = "099720109477" + name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" + }, + centos7 = { + owner-id = "125523088429" + name = "CentOS 7.*x86_64" + }, + centos8 = { + owner-id = "125523088429" + name = "CentOS 8.*x86_64" + }, + arch = { + owner-id = "093273469852" + name = "arch-linux-lts-hvm*x86_64-ebs" + }, + rhel7 = { + owner-id = "309956199498" + name = "RHEL-7.*HVM*x86_64*GP2" + }, + rhel8 = { + owner-id = "309956199498" + name = "RHEL-8.*HVM*x86_64*GP2" + } + } +} + +data "aws_ami" "amis" { + for_each = local.amis + most_recent = true + owners = [each.value.owner-id] + + filter { + name = "name" + values = [each.value.name] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + filter { + name = "architecture" + values = ["x86_64"] + } + + filter { + name = "root-device-type" + values = ["ebs"] + } +} diff --git a/modules/aws-amis/outputs.tf b/modules/aws-amis/outputs.tf new file mode 100644 index 0000000..3174fd9 --- /dev/null +++ b/modules/aws-amis/outputs.tf @@ -0,0 +1,3 @@ +output "amis" { + value = tomap({ for type, ami in data.aws_ami.amis : type => ami.id }) +} From 9aa0a68be81dab001a916ace5fb69bf4a4a3dae1 Mon Sep 17 00:00:00 2001 From: shnee Date: Wed, 17 Nov 2021 21:50:07 -0500 Subject: [PATCH 3/6] AWS nodes and user-data created from config map. --- example.tfvars | 23 ++++++- main.tf | 83 +++++++++----------------- modules/cloud-init-config/main.tf | 9 +++ modules/cloud-init-config/outputs.tf | 3 + modules/cloud-init-config/variables.tf | 22 +++++++ variables.tf | 5 ++ 6 files changed, 90 insertions(+), 55 deletions(-) create mode 100644 modules/cloud-init-config/main.tf create mode 100644 modules/cloud-init-config/outputs.tf create mode 100644 modules/cloud-init-config/variables.tf diff --git a/example.tfvars b/example.tfvars index 4b6100d..4ea7b3c 100644 --- a/example.tfvars +++ b/example.tfvars @@ -1,4 +1,4 @@ -vm-name-prefix = "docker-ansible-test" +vm-name-prefix = "k8s-tf" # A CIDR block ending in '/32' equates to a single IP address, '0.0.0.0/0' # equates to any ip address. @@ -13,6 +13,10 @@ worker-nodes = 2 node-memory = 2048 node-vcpus = 2 +################################################################################ +# AWS EC2 instance types +################################################################################ + # 1 GiB, 1 vcpu, only one that is free. # This one won't work with k8s because it requires at least 2 vcpus. aws-ec2-instance-type = "t2.micro" @@ -20,6 +24,19 @@ aws-ec2-instance-type = "t2.micro" # 4 GiB, 2 vcpus # aws-ec2-instnce-type = "t2.medium" +################################################################################ + +nodes-config = { + "master" = { + base-image = "ami-0dd0ccab7e2801812" + num = 1 + }, + "worker" = { + base-image = "ami-0dd0ccab7e2801812" + num = 2 + } +} + ################################################################################ # AWS images (AMIs) ################################################################################ @@ -53,6 +70,10 @@ base-image = "ami-0dd0ccab7e2801812" # From https://cloud.centos.org/centos/7/images/ from 2020-11-12 06:52 # base-image = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2" +################################################################################ +# Keys/Passwords +################################################################################ + # Password hash created with: # python3 -c 'import crypt; print(crypt.crypt("linux", crypt.mksalt(crypt.METHOD_SHA512)))' # where "linux" is the password. diff --git a/main.tf b/main.tf index 69c7943..ce42da9 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,8 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 1.0.8" required_providers { libvirt = { - source = "dmacvicar/libvirt" + source = "dmacvicar/libvirt" version = "0.6.11" } } @@ -12,24 +12,14 @@ terraform { # cloud-init ################################################################################ -data "template_file" "master-node-user-datas" { - template = file("${path.module}/cloud_init.cfg") - vars = { - admin-passwd = "${var.root-admin-passwd}" - admin-pub-key = "${var.root-admin-pub-key}" - hostname = "${var.vm-name-prefix}-master-${count.index}" - } - count = var.master-nodes -} - -data "template_file" "worker-node-user-datas" { - template = file("${path.module}/cloud_init.cfg") - vars = { - admin-passwd = "${var.root-admin-passwd}" - admin-pub-key = "${var.root-admin-pub-key}" - hostname = "${var.vm-name-prefix}-worker-${count.index}" - } - count = var.worker-nodes +module "cloud-init-config" { + for_each = var.nodes-config + source = "./modules/cloud-init-config" + cloud-init-template = "${path.module}/cloud_init.cfg" + hostname-prefix = "${var.vm-name-prefix}-${each.key}" + num = each.value.num + root-admin-passwd = var.root-admin-passwd + root-admin-pub-key = var.root-admin-pub-key } ################################################################################ @@ -42,16 +32,20 @@ provider "aws" { region = "us-east-2" } -module "aws-amis" { - source = "./modules/aws-amis" -} +# This module will grab the latest ami for a variety of distros. +# module "aws-amis" { +# source = "./modules/aws-amis" +# } +# output "amis" { +# value = module.aws-amis.amis +# } module "aws-network" { - source = "./modules/aws-network" - name-prefix = var.vm-name-prefix - vpc-cidr-block = var.aws-vpc-cidr-block + source = "./modules/aws-network" + name-prefix = var.vm-name-prefix + vpc-cidr-block = var.aws-vpc-cidr-block subnet-cidr-block = var.aws-subnet-cidr-block - admin-ips = var.admin-ips + admin-ips = var.admin-ips } # This key pair is not actually used. Keys are added to the nodes via cloud-init @@ -64,30 +58,16 @@ resource "aws_key_pair" "key" { } } -module "master-nodes" { +module "nodes" { + for_each = var.nodes-config source = "./modules/aws-nodes" - ami = var.base-image + ami = each.value.base-image ec2-instance-type = var.aws-ec2-instance-type subnet-id = module.aws-network.subnet.id security-group-ids = [module.aws-network.default-security-group.id] - user-datas = data.template_file.master-node-user-datas - num-nodes = var.master-nodes - name-prefix = "${var.vm-name-prefix}-master" -} - -module "worker-nodes" { - source = "./modules/aws-nodes" - ami = var.base-image - ec2-instance-type = var.aws-ec2-instance-type - subnet-id = module.aws-network.subnet.id - security-group-ids = [module.aws-network.default-security-group.id] - user-datas = data.template_file.worker-node-user-datas - num-nodes = var.worker-nodes - name-prefix = "${var.vm-name-prefix}-worker" -} - -output "amis" { - value = module.aws-amis.amis + user-datas = lookup(module.cloud-init-config, each.key, null).user-datas + num-nodes = each.value.num + name-prefix = "${var.vm-name-prefix}-${each.key}" } ################################################################################ @@ -142,11 +122,6 @@ output "amis" { # end libvirt ################################################################################ -# TODO REM move to other file? -output "master-ips" { - value = module.master-nodes.ips -} - -output "worker-ips" { - value = module.worker-nodes.ips +output "ips" { + value = { for type, node in module.nodes : type => node.ips } } diff --git a/modules/cloud-init-config/main.tf b/modules/cloud-init-config/main.tf new file mode 100644 index 0000000..e1c75c4 --- /dev/null +++ b/modules/cloud-init-config/main.tf @@ -0,0 +1,9 @@ +data "template_file" "user-datas" { + template = file("${var.cloud-init-template}") + vars = { + admin-passwd = "${var.root-admin-passwd}" + admin-pub-key = "${var.root-admin-pub-key}" + hostname = "${var.hostname-prefix}-${count.index}" + } + count = var.num +} diff --git a/modules/cloud-init-config/outputs.tf b/modules/cloud-init-config/outputs.tf new file mode 100644 index 0000000..15415d4 --- /dev/null +++ b/modules/cloud-init-config/outputs.tf @@ -0,0 +1,3 @@ +output "user-datas" { + value = data.template_file.user-datas +} diff --git a/modules/cloud-init-config/variables.tf b/modules/cloud-init-config/variables.tf new file mode 100644 index 0000000..fc4f437 --- /dev/null +++ b/modules/cloud-init-config/variables.tf @@ -0,0 +1,22 @@ +variable "cloud-init-template" { + default = "../../cloud_init.cfg" + description = "The path to the cloud-init config template." + type = string +} + +variable "hostname-prefix" { + description = "This prefix wil be applied as a prefix for the hostnames." +} + +variable "num" { + description = "The number of user-datas to create with these parameters." +} + +variable "root-admin-passwd" { + description = "This value will be substituted for any occurence of 'admin-password' in the cloud-init config template." +} + +variable "root-admin-pub-key" { + description = "This value will be substituted for any occurence of 'admin-pub-key' in the cloud-init config template." +} + diff --git a/variables.tf b/variables.tf index 52cf7a2..e8f3211 100644 --- a/variables.tf +++ b/variables.tf @@ -43,6 +43,11 @@ variable "node-vcpus" { type = number } +variable "nodes-config" { + description = "A config that declares how many nodes of each type you want created." + type = map(object({base-image=string,num=number})) +} + variable "root-admin-passwd" { description = "This will be the password for the root and admin user. The format of this can by any format accepted by cloud-init's chpasswd module." } From c9ea3d448971856c152af05f7857e8646bdbbae1 Mon Sep 17 00:00:00 2001 From: shnee Date: Thu, 18 Nov 2021 09:45:16 -0500 Subject: [PATCH 4/6] Make libvirt module accept config map. --- example.tfvars | 3 --- main.tf | 25 ++++++------------------- modules/libvirt-nodes/main.tf | 4 ---- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/example.tfvars b/example.tfvars index 4ea7b3c..df3f604 100644 --- a/example.tfvars +++ b/example.tfvars @@ -7,9 +7,6 @@ admin-ips = [ "8.8.8.8/32", "0.0.0.0/0" ] disk-image-dir = "/path/to/disk/pool/" libvirt-connection-url = "qemu+ssh://@/system" -master-nodes = 1 -worker-nodes = 2 - node-memory = 2048 node-vcpus = 2 diff --git a/main.tf b/main.tf index ce42da9..7510f3e 100644 --- a/main.tf +++ b/main.tf @@ -84,32 +84,19 @@ module "nodes" { # uri = var.libvirt-connection-url # } # -# module "master-nodes" { +# module "nodes" { +# for_each = var.nodes-config # source = "./modules/libvirt-nodes" # pool-name = libvirt_pool.images.name -# name-prefix = "${var.vm-name-prefix}-master" -# num-nodes = var.master-nodes +# name-prefix = "${var.vm-name-prefix}-${each.key}" +# num-nodes = each.value.num # node-memory = var.node-memory # node-vcpus = var.node-vcpus -# base-image = var.base-image +# base-image = each.value.base-image # root-admin-passwd = var.root-admin-passwd # root-admin-pub-key = var.root-admin-pub-key # libvirt-connection-url = var.libvirt-connection-url -# user-datas = data.template_file.master-node-user-datas -# } -# -# module "worker-nodes" { -# source = "./modules/libvirt-nodes" -# pool-name = libvirt_pool.images.name -# name-prefix = "${var.vm-name-prefix}-worker" -# num-nodes = var.worker-nodes -# node-memory = var.node-memory -# node-vcpus = var.node-vcpus -# base-image = var.base-image -# root-admin-passwd = var.root-admin-passwd -# root-admin-pub-key = var.root-admin-pub-key -# libvirt-connection-url = var.libvirt-connection-url -# user-datas = data.template_file.worker-node-user-datas +# user-datas = lookup(module.cloud-init-config, each.key, null).user-datas # } # # resource "libvirt_pool" "images" { diff --git a/modules/libvirt-nodes/main.tf b/modules/libvirt-nodes/main.tf index 9b792d0..cbd0dac 100644 --- a/modules/libvirt-nodes/main.tf +++ b/modules/libvirt-nodes/main.tf @@ -8,10 +8,6 @@ terraform { } } -provider "libvirt" { - uri = var.libvirt-connection-url -} - resource "libvirt_volume" "node-images" { name = "${var.name-prefix}-${count.index}" pool = var.pool-name From 852d8cfcf2f6838af7bbadc56ddaaf01b6413203 Mon Sep 17 00:00:00 2001 From: shnee Date: Thu, 18 Nov 2021 10:45:58 -0500 Subject: [PATCH 5/6] Update get-vm-ips.sh to work with new map config. --- get-vm-ips.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/get-vm-ips.sh b/get-vm-ips.sh index 8eceb68..230b5cf 100755 --- a/get-vm-ips.sh +++ b/get-vm-ips.sh @@ -22,7 +22,7 @@ IPS_JSON="$( # An array of all node "types" NODE_TYPE_ARRAY="$( echo $IPS_JSON | \ - jq '.key' | \ + jq '.value.value | to_entries | .[] | .key' | \ sed 's/"//g' | \ sed -z 's/\n/ /g;s/ $/\n/g')" @@ -32,12 +32,12 @@ VM_IP_EXPORTS="$( # Convert type, converts "master-ips" to "MASTER" TYPE_UPPER="$(echo ${TYPE^^} | sed s/_.*$//g)" - echo "$OUTPUTS_JSON" | \ - jq '.'"$TYPE"'.value[]' | \ + echo "$IPS_JSON" | \ + jq '.value.value.'"$TYPE"'[]' | \ # Add line numbers starting with 0. nl -v 0 | \ # Print an export string with a type placeholder "__TYPE__". - awk '{print "export __TYPE__" $1 "=" $2}' | \ + awk '{print "export __TYPE___" $1 "=" $2}' | \ sed s/__TYPE__/$TYPE_UPPER/g done)" From ec6bb824d0ff6ce8d0d6aec1e1000bf534d3f85b Mon Sep 17 00:00:00 2001 From: shnee Date: Thu, 18 Nov 2021 11:19:59 -0500 Subject: [PATCH 6/6] Moved node-config to be local, added AMI vars. --- example.tfvars | 13 ------------- get-vm-ips.sh | 1 + main.tf | 22 ++++++++++++++++++---- variables.tf | 41 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/example.tfvars b/example.tfvars index df3f604..41ca648 100644 --- a/example.tfvars +++ b/example.tfvars @@ -21,19 +21,6 @@ aws-ec2-instance-type = "t2.micro" # 4 GiB, 2 vcpus # aws-ec2-instnce-type = "t2.medium" -################################################################################ - -nodes-config = { - "master" = { - base-image = "ami-0dd0ccab7e2801812" - num = 1 - }, - "worker" = { - base-image = "ami-0dd0ccab7e2801812" - num = 2 - } -} - ################################################################################ # AWS images (AMIs) ################################################################################ diff --git a/get-vm-ips.sh b/get-vm-ips.sh index 230b5cf..cbdc820 100755 --- a/get-vm-ips.sh +++ b/get-vm-ips.sh @@ -48,6 +48,7 @@ ANSIBLE_INV="$( sed -z 's/\n/,/g;s/,$/\n/g')" # Create an inventory file for ansible. +echo "# Wrote an Ansible inventory file at ./inventory" echo "[k8s_nodes]" > inventory echo $VM_IP_EXPORTS | \ sed 's/"//g' | \ diff --git a/main.tf b/main.tf index 7510f3e..caa213c 100644 --- a/main.tf +++ b/main.tf @@ -8,12 +8,25 @@ terraform { } } +locals { + nodes-config = { + "master" = { + base-image = var.amzn2-ami + num = 1 + }, + "worker" = { + base-image = var.amzn2-ami + num = 2 + } + } +} + ################################################################################ # cloud-init ################################################################################ module "cloud-init-config" { - for_each = var.nodes-config + for_each = local.nodes-config source = "./modules/cloud-init-config" cloud-init-template = "${path.module}/cloud_init.cfg" hostname-prefix = "${var.vm-name-prefix}-${each.key}" @@ -32,7 +45,8 @@ provider "aws" { region = "us-east-2" } -# This module will grab the latest ami for a variety of distros. +# This module will grab the latest ami for a variety of distros. Uncomment to +# get a list of the latest AMIs for our supported distros. # module "aws-amis" { # source = "./modules/aws-amis" # } @@ -59,7 +73,7 @@ resource "aws_key_pair" "key" { } module "nodes" { - for_each = var.nodes-config + for_each = local.nodes-config source = "./modules/aws-nodes" ami = each.value.base-image ec2-instance-type = var.aws-ec2-instance-type @@ -85,7 +99,7 @@ module "nodes" { # } # # module "nodes" { -# for_each = var.nodes-config +# for_each = local.nodes-config # source = "./modules/libvirt-nodes" # pool-name = libvirt_pool.images.name # name-prefix = "${var.vm-name-prefix}-${each.key}" diff --git a/variables.tf b/variables.tf index e8f3211..3719268 100644 --- a/variables.tf +++ b/variables.tf @@ -43,11 +43,6 @@ variable "node-vcpus" { type = number } -variable "nodes-config" { - description = "A config that declares how many nodes of each type you want created." - type = map(object({base-image=string,num=number})) -} - variable "root-admin-passwd" { description = "This will be the password for the root and admin user. The format of this can by any format accepted by cloud-init's chpasswd module." } @@ -76,3 +71,39 @@ variable "vm-name-prefix" { default = "k8s-tf" description = "This prefix will appear before all VM names and hostnames, ie. k8s-tf-master-0." } + +################################################################################ +# AWS AMI vars +# These variables are really mor like constants. Using variables improves +# readability. The defaults are manually updated. Use the aws-amis module to get +# the latest for each distro. +################################################################################ + +variable "amzn2-ami" { + default = "ami-0dd0ccab7e2801812" + description = "The AMI to use for Amazon Linux 2." +} +variable "ubuntu-ami" { + default = "ami-06c7d6c0987eaa46c" + description = "The AMI to use for Ubuntu." +} +variable "centos7-ami" { + default = "ami-00f8e2c955f7ffa9b" + description = "The AMI to use for CentOS 7." +} +variable "centos8-ami" { + default = "ami-057cacbfbbb471bb3" + description = "The AMI to use for CentOS 8." +} +variable "arch-ami" { + default = "ami-02653f06de985e3ba" + description = "The AMI to use for Arch Linux." +} +variable "rhel7-ami" { + default = "ami-0a509b3c2a4d05b3f" + description = "The AMI to use for RHEL 7." +} +variable "rhel8-ami" { + default = "ami-0d871ca8a77af2948" + description = "The AMI to use for RHEL 8." +}