|
|
|
@ -1,5 +1,5 @@
|
|
|
|
terraform {
|
|
|
|
terraform {
|
|
|
|
required_version = ">= 0.13"
|
|
|
|
required_version = ">= 1.0.8"
|
|
|
|
required_providers {
|
|
|
|
required_providers {
|
|
|
|
libvirt = {
|
|
|
|
libvirt = {
|
|
|
|
source = "dmacvicar/libvirt"
|
|
|
|
source = "dmacvicar/libvirt"
|
|
|
|
@ -8,78 +8,31 @@ terraform {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
locals {
|
|
|
|
# cloud-init
|
|
|
|
nodes-config = {
|
|
|
|
################################################################################
|
|
|
|
"master" = {
|
|
|
|
|
|
|
|
base-image = var.amzn2-ami
|
|
|
|
# data "template_file" "master-node-user-datas" {
|
|
|
|
num = 1
|
|
|
|
# template = file("${path.module}/cloud_init.cfg")
|
|
|
|
},
|
|
|
|
# vars = {
|
|
|
|
"worker" = {
|
|
|
|
# admin-passwd = "${var.root-admin-passwd}"
|
|
|
|
base-image = var.amzn2-ami
|
|
|
|
# admin-pub-key = "${var.root-admin-pub-key}"
|
|
|
|
num = 2
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data "template_file" "amzn2-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}-amzn2-${count.index}"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data "template_file" "ubuntu-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}-ubuntu-${count.index}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data "template_file" "arch-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}-arch-${count.index}"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data "template_file" "centos7-node-user-datas" {
|
|
|
|
################################################################################
|
|
|
|
template = file("${path.module}/cloud_init.cfg")
|
|
|
|
# cloud-init
|
|
|
|
vars = {
|
|
|
|
################################################################################
|
|
|
|
admin-passwd = "${var.root-admin-passwd}"
|
|
|
|
|
|
|
|
admin-pub-key = "${var.root-admin-pub-key}"
|
|
|
|
|
|
|
|
hostname = "${var.vm-name-prefix}-centos7-${count.index}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data "template_file" "centos8-node-user-datas" {
|
|
|
|
module "cloud-init-config" {
|
|
|
|
template = file("${path.module}/cloud_init.cfg")
|
|
|
|
for_each = local.nodes-config
|
|
|
|
vars = {
|
|
|
|
source = "./modules/cloud-init-config"
|
|
|
|
admin-passwd = "${var.root-admin-passwd}"
|
|
|
|
cloud-init-template = "${path.module}/cloud_init.cfg"
|
|
|
|
admin-pub-key = "${var.root-admin-pub-key}"
|
|
|
|
hostname-prefix = "${var.vm-name-prefix}-${each.key}"
|
|
|
|
hostname = "${var.vm-name-prefix}-centos8-${count.index}"
|
|
|
|
num = each.value.num
|
|
|
|
}
|
|
|
|
root-admin-passwd = var.root-admin-passwd
|
|
|
|
count = 1
|
|
|
|
root-admin-pub-key = var.root-admin-pub-key
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
@ -92,9 +45,14 @@ provider "aws" {
|
|
|
|
region = "us-east-2"
|
|
|
|
region = "us-east-2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module "aws-amis" {
|
|
|
|
# This module will grab the latest ami for a variety of distros. Uncomment to
|
|
|
|
source = "./modules/aws-amis"
|
|
|
|
# get a list of the latest AMIs for our supported distros.
|
|
|
|
}
|
|
|
|
# module "aws-amis" {
|
|
|
|
|
|
|
|
# source = "./modules/aws-amis"
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
# output "amis" {
|
|
|
|
|
|
|
|
# value = module.aws-amis.amis
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
module "aws-network" {
|
|
|
|
module "aws-network" {
|
|
|
|
source = "./modules/aws-network"
|
|
|
|
source = "./modules/aws-network"
|
|
|
|
@ -114,87 +72,18 @@ resource "aws_key_pair" "key" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module "amzn2-nodes" {
|
|
|
|
module "nodes" {
|
|
|
|
|
|
|
|
for_each = local.nodes-config
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
ami = var.base-image
|
|
|
|
ami = each.value.base-image
|
|
|
|
ec2-instance-type = var.aws-ec2-instance-type
|
|
|
|
ec2-instance-type = var.aws-ec2-instance-type
|
|
|
|
subnet-id = module.aws-network.subnet.id
|
|
|
|
subnet-id = module.aws-network.subnet.id
|
|
|
|
security-group-ids = [module.aws-network.default-security-group.id]
|
|
|
|
security-group-ids = [module.aws-network.default-security-group.id]
|
|
|
|
user-datas = data.template_file.amzn2-node-user-datas
|
|
|
|
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
|
|
|
|
num-nodes = 1
|
|
|
|
num-nodes = each.value.num
|
|
|
|
name-prefix = "${var.vm-name-prefix}-amzn2"
|
|
|
|
name-prefix = "${var.vm-name-prefix}-${each.key}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module "ubuntu-nodes" {
|
|
|
|
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
|
|
|
|
ami = "ami-0629230e074c580f2"
|
|
|
|
|
|
|
|
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.ubuntu-node-user-datas
|
|
|
|
|
|
|
|
num-nodes = 1
|
|
|
|
|
|
|
|
name-prefix = "${var.vm-name-prefix}-ubuntu"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module "arch-nodes" {
|
|
|
|
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
|
|
|
|
ami = "ami-02653f06de985e3ba"
|
|
|
|
|
|
|
|
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.ubuntu-node-user-datas
|
|
|
|
|
|
|
|
num-nodes = 1
|
|
|
|
|
|
|
|
name-prefix = "${var.vm-name-prefix}-arch"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module "centos7-nodes" {
|
|
|
|
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
|
|
|
|
ami = "ami-00f8e2c955f7ffa9b"
|
|
|
|
|
|
|
|
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.ubuntu-node-user-datas
|
|
|
|
|
|
|
|
num-nodes = 1
|
|
|
|
|
|
|
|
name-prefix = "${var.vm-name-prefix}-centos7"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module "centos8-nodes" {
|
|
|
|
|
|
|
|
source = "./modules/aws-nodes"
|
|
|
|
|
|
|
|
ami = "ami-057cacbfbbb471bb3"
|
|
|
|
|
|
|
|
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.ubuntu-node-user-datas
|
|
|
|
|
|
|
|
num-nodes = 1
|
|
|
|
|
|
|
|
name-prefix = "${var.vm-name-prefix}-centos8"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "amis" {
|
|
|
|
|
|
|
|
value = module.aws-amis.amis
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# module "master-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.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"
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
# end aws
|
|
|
|
# end aws
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
@ -209,32 +98,19 @@ output "amis" {
|
|
|
|
# uri = var.libvirt-connection-url
|
|
|
|
# uri = var.libvirt-connection-url
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# module "master-nodes" {
|
|
|
|
# module "nodes" {
|
|
|
|
|
|
|
|
# for_each = local.nodes-config
|
|
|
|
# source = "./modules/libvirt-nodes"
|
|
|
|
# source = "./modules/libvirt-nodes"
|
|
|
|
# pool-name = libvirt_pool.images.name
|
|
|
|
# pool-name = libvirt_pool.images.name
|
|
|
|
# name-prefix = "${var.vm-name-prefix}-master"
|
|
|
|
# name-prefix = "${var.vm-name-prefix}-${each.key}"
|
|
|
|
# num-nodes = var.master-nodes
|
|
|
|
# num-nodes = each.value.num
|
|
|
|
# node-memory = var.node-memory
|
|
|
|
# node-memory = var.node-memory
|
|
|
|
# node-vcpus = var.node-vcpus
|
|
|
|
# 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-passwd = var.root-admin-passwd
|
|
|
|
# root-admin-pub-key = var.root-admin-pub-key
|
|
|
|
# root-admin-pub-key = var.root-admin-pub-key
|
|
|
|
# libvirt-connection-url = var.libvirt-connection-url
|
|
|
|
# libvirt-connection-url = var.libvirt-connection-url
|
|
|
|
# user-datas = data.template_file.master-node-user-datas
|
|
|
|
# user-datas = lookup(module.cloud-init-config, each.key, null).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
|
|
|
|
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# resource "libvirt_pool" "images" {
|
|
|
|
# resource "libvirt_pool" "images" {
|
|
|
|
@ -247,31 +123,6 @@ output "amis" {
|
|
|
|
# end libvirt
|
|
|
|
# end libvirt
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
output "amzn2-ips" {
|
|
|
|
output "ips" {
|
|
|
|
value = module.amzn2-nodes.ips
|
|
|
|
value = { for type, node in module.nodes : type => node.ips }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "ubuntu-ips" {
|
|
|
|
|
|
|
|
value = module.ubuntu-nodes.ips
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "arch-ips" {
|
|
|
|
|
|
|
|
value = module.arch-nodes.ips
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "centos7-ips" {
|
|
|
|
|
|
|
|
value = module.centos7-nodes.ips
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "centos8-ips" {
|
|
|
|
|
|
|
|
value = module.centos8-nodes.ips
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# TODO REM move to other file?
|
|
|
|
|
|
|
|
# output "master-ips" {
|
|
|
|
|
|
|
|
# value = module.master-nodes.ips
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# output "worker-ips" {
|
|
|
|
|
|
|
|
# value = module.worker-nodes.ips
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|